diff --git a/src/constants/format.ts b/src/constants/format.ts index 9e39128..dd9db12 100644 --- a/src/constants/format.ts +++ b/src/constants/format.ts @@ -1,2 +1,12 @@ +import type {LongDateFormat} from '../settings/types'; + export const DEFAULT_SYSTEM_DATE_FORMAT = 'YYYY-MM-DD'; export const INVALID_DATE_STRING = 'Invalid Date'; +export const englishFormats = { + LTS: 'h:mm:ss A', + LT: 'h:mm A', + L: 'MM/DD/YYYY', + LL: 'MMMM D, YYYY', + LLL: 'MMMM D, YYYY h:mm A', + LLLL: 'dddd, MMMM D, YYYY h:mm A', +} as const satisfies LongDateFormat; diff --git a/src/dateTime/format.ts b/src/dateTime/format.ts index 0c7f7bc..68dadce 100644 --- a/src/dateTime/format.ts +++ b/src/dateTime/format.ts @@ -1,17 +1,9 @@ +import {englishFormats} from '../constants'; import {settings} from '../settings'; import type {Locale, LongDateFormat} from '../settings/types'; import {parseZoneInfo} from '../timeZone'; import type {DateTime} from '../typings'; -export const englishFormats = { - LTS: 'h:mm:ss A', - LT: 'h:mm A', - L: 'MM/DD/YYYY', - LL: 'MMMM D, YYYY', - LLL: 'MMMM D, YYYY h:mm A', - LLLL: 'dddd, MMMM D, YYYY h:mm A', -} satisfies LongDateFormat; - function getShortLocalizedFormatFromLongLocalizedFormat(formatBis: string) { return formatBis.replace( /(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, diff --git a/src/dayjs/index.ts b/src/dayjs/index.ts index f416cd2..ef6c36c 100644 --- a/src/dayjs/index.ts +++ b/src/dayjs/index.ts @@ -3,10 +3,14 @@ import customParseFormat from 'dayjs/plugin/customParseFormat'; import updateLocale from 'dayjs/plugin/updateLocale'; import utc from 'dayjs/plugin/utc'; +import {englishFormats} from '../constants'; + dayjs.extend(customParseFormat); dayjs.extend(utc); dayjs.extend(updateLocale); +dayjs.Ls['en'].formats = englishFormats; + export default dayjs; export type {ConfigTypeMap, ConfigType} from 'dayjs';