Skip to content

Commit

Permalink
fix: formatBirthDate bug (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppvg authored Jun 30, 2021
1 parent d78e1bd commit 97a5fa3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@ import { t } from "./i18n";
import { isNumeric, padLeft } from "./util";

/**
* @param {import("./types").Locale} locale
* @param {string|number} month
* @param {import("./types").Locale} locale
* @return {string}
*/
export const monthNameShort = (locale, month) => t("date.months.abbr." + month);
export const monthNameShort = (month, locale) =>
t(locale, "date.months.abbr." + month);

/**
* @param {string} birthDay
* @param {string} birthMonth
* @param {import("./types").Locale} locale
* @return {string}
*/
export const formatBirthDate = (birthDay, birthMonth) => {
export const formatBirthDate = (birthDay, birthMonth, locale) => {
const birthDayShort = isNumeric(birthDay)
? padLeft(birthDay, 2, "0")
: birthDay;
const birthMonthShort = isNumeric(birthMonth)
? monthNameShort(birthMonth)
? monthNameShort(birthMonth, locale)
: birthMonth;
return birthDayShort + " " + birthMonthShort;
};
Expand Down
3 changes: 2 additions & 1 deletion src/proofs.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ const domesticProof = (data) => {

birthDateStringShort: formatBirthDate(
data.attributes.birthDay,
data.attributes.birthMonth
data.attributes.birthMonth,
"nl"
),

validFromDate,
Expand Down
2 changes: 1 addition & 1 deletion src/util.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const NUM = /^\d+&/;
const NUM = /^\d+$/;

/**
* @param {string} input
Expand Down

0 comments on commit 97a5fa3

Please sign in to comment.