Skip to content

Commit 9b3c515

Browse files
Patricio AlbizuPatricio Albizu
authored andcommitted
feat: add full month and year formatter
1 parent 404794d commit 9b3c515

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

projects/common/src/utilities/formatters/date/date-formatter.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ describe('Date formatter', () => {
1414
}).format(dateString)
1515
).toEqual('Aug 21');
1616
});
17+
18+
test('can format a date string with full month and year only', () => {
19+
expect(
20+
new DateFormatter({
21+
mode: DateFormatMode.FullMonthAndYearOnly
22+
}).format(dateString)
23+
).toEqual('August 2021');
24+
});
1725
});

projects/common/src/utilities/formatters/date/date-formatter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const enum DateFormatMode {
88
DateOnly,
99
MonthAndDayOnly,
1010
MonthAndYearOnly,
11+
FullMonthAndYearOnly,
1112
DateAndTime,
1213
DateAndTimeWithSeconds
1314
}
@@ -54,6 +55,8 @@ export class DateFormatter {
5455
return 'MMM d';
5556
case DateFormatMode.MonthAndYearOnly:
5657
return 'MMM yy';
58+
case DateFormatMode.FullMonthAndYearOnly:
59+
return 'MMMM yyyy';
5760
case DateFormatMode.DateOnly:
5861
return 'd MMM y';
5962
case DateFormatMode.DateAndTime:

0 commit comments

Comments
 (0)