Skip to content

Commit

Permalink
feat(time): add meridian template
Browse files Browse the repository at this point in the history
  • Loading branch information
maurodesouza committed May 1, 2024
1 parent bdc5d4f commit 96f4a5f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/util/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ export function format(
const m = date[minutesGetterName(isUTC)]();
const s = date[secondsGetterName(isUTC)]();
const S = date[millisecondsGetterName(isUTC)]();

const a = H >= 12 ? 'pm' : 'am';
const A = a.toUpperCase();

const localeModel = lang instanceof Model ? lang
: getLocaleModel(lang || SYSTEM_LANG) || getDefaultLocaleModel();
Expand All @@ -132,6 +133,8 @@ export function format(
const dayOfWeekAbbr = timeModel.get('dayOfWeekAbbr');

return (template || '')
.replace(/{a}/g, a + '')
.replace(/{A}/g, A + '')
.replace(/{yyyy}/g, y + '')
.replace(/{yy}/g, pad(y % 100 + '', 2))
.replace(/{Q}/g, q + '')
Expand Down
16 changes: 15 additions & 1 deletion test/ut/spec/util/time.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 96f4a5f

Please sign in to comment.