Skip to content

Commit

Permalink
fix: month abbreviation locale in domestic proof (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppvg authored Jul 2, 2021
1 parent 3ccf2a0 commit 70b4327
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions src/proofs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import {
* TODO any type
* @param {import("./types").ProofData} proofData
* @param {any} holderConfig
* @param {import("./types").Locale} [locale]
* @return {import("./types").Proof[]}
*/
export const parseProofData = (proofData, holderConfig) => {
export const parseProofData = (proofData, holderConfig, locale) => {
/** @type {import("./types").Proof[]} */
const proofs = [];

if (proofData.domestic) {
proofs.push(domesticProof(proofData.domestic));
proofs.push(domesticProof(proofData.domestic, locale));
}
if (proofData.european) {
for (const proof of europeanProofs(proofData.european, holderConfig)) {
Expand All @@ -31,9 +32,10 @@ export const parseProofData = (proofData, holderConfig) => {

/**
* @param {import("./types").DomesticProofData} data
* @param {import("./types").Locale} [locale]
* @return {import("./types").Proof}
*/
const domesticProof = (data) => {
const domesticProof = (data, locale) => {
const validFromDate = parseInt(data.attributes.validFrom, 10) * 1000;
return {
proofType: "domestic",
Expand All @@ -53,7 +55,7 @@ const domesticProof = (data) => {
birthDateStringShort: formatBirthDate(
data.attributes.birthDay,
data.attributes.birthMonth,
"nl"
locale || "nl"
),

validFromDate,
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"include": ["src/**/*"],
"compilerOptions": {
"allowJs": false,
"checkJs": false,
"allowJs": true,
"checkJs": true,
"declaration": true,
"emitDeclarationOnly": true,
"moduleResolution": "node",
Expand Down
4 changes: 2 additions & 2 deletions types/date.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function monthNameShort(locale: import("./types").Locale, month: string | number): string;
export function formatBirthDate(birthDay: string, birthMonth: string): string;
export function monthNameShort(month: string | number, locale: import("./types").Locale): string;
export function formatBirthDate(birthDay: string, birthMonth: string, locale: import("./types").Locale): string;
export function formatDate(dateTimeMs: number | Date): string;
export function formatDateTime(dateTimeMs: number | Date): string;
export function hoursInMs(hours: string): number;
2 changes: 1 addition & 1 deletion types/proofs.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export function parseProofData(proofData: import("./types").ProofData, holderConfig: any): import("./types").Proof[];
export function parseProofData(proofData: import("./types").ProofData, holderConfig: any, locale?: import("./types").Locale): import("./types").Proof[];

0 comments on commit 70b4327

Please sign in to comment.