Skip to content

Commit

Permalink
fix(locale): add formats to en locale (#64)
Browse files Browse the repository at this point in the history
Co-authored-by: Mr.Dr.Professor Patrick <[email protected]>
  • Loading branch information
ValeraS and korvin89 authored May 23, 2024
1 parent 54b77be commit 8e2025e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/constants/format.ts
Original file line number Diff line number Diff line change
@@ -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;
10 changes: 1 addition & 9 deletions src/dateTime/format.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
4 changes: 4 additions & 0 deletions src/dayjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit 8e2025e

Please sign in to comment.