diff --git a/src/dayjs.ts b/src/dayjs.ts index 3251792..e1893cc 100644 --- a/src/dayjs.ts +++ b/src/dayjs.ts @@ -8,6 +8,7 @@ import quarterOfYear from 'dayjs/plugin/quarterOfYear'; import relativeTime from 'dayjs/plugin/relativeTime'; import timezone from 'dayjs/plugin/timezone'; import utc from 'dayjs/plugin/utc'; +import localizedFormat from 'dayjs/plugin/localizedFormat'; import updateLocale from 'dayjs/plugin/updateLocale'; dayjs.extend(arraySupport); @@ -17,6 +18,7 @@ dayjs.extend(quarterOfYear); dayjs.extend(relativeTime); dayjs.extend(timezone); dayjs.extend(utc); +dayjs.extend(localizedFormat); dayjs.extend(updateLocale); // the modifications made in objectSupport would preserve other plugins behavior // but not vice versa, therefore it should come last diff --git a/src/index.test.ts b/src/index.test.ts index eaa73d4..ff82adc 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -44,4 +44,18 @@ describe('Public API', () => { it('year quarters are supported', () => { expect(date.startOf('Q').format('YYYY-MM-DD')).toBe('2000-01-01'); }); + + it('localized formats are supported', () => { + expect(date.locale('en').format('L')).toBe('02/02/2000'); + expect(date.locale('ru').format('L')).toBe('02.02.2000'); + + expect(date.locale('en').format('LL')).toBe('February 2, 2000'); + expect(date.locale('ru').format('LL')).toBe('2 февраля 2000 г.'); + + expect(date.locale('en').format('LT')).toBe('12:00 AM'); + expect(date.locale('ru').format('LT')).toBe('0:00'); + + expect(date.locale('en').format('LTS')).toBe('12:00:00 AM'); + expect(date.locale('ru').format('LTS')).toBe('0:00:00'); + }); });