19 lines
580 B
TypeScript
19 lines
580 B
TypeScript
import type { Locale } from 'date-fns';
|
|
import * as locales from 'date-fns/locale';
|
|
import type { IntlDateDisplayFormatEnum } from '../constants';
|
|
|
|
export type IntlDateLocaleCode = keyof typeof locales;
|
|
export type IntlDateLanguage = string;
|
|
|
|
export type IntlDateLocaleMap = Partial<Record<IntlDateLanguage, IntlDateLocaleConfig>>;
|
|
|
|
export type IntlDateLocaleConfig = {
|
|
code: IntlDateLocaleCode;
|
|
locale?: Locale;
|
|
displayFormats?: Partial<Record<IntlDateDisplayFormatEnum, string>>;
|
|
};
|
|
|
|
export function getLocale(lang: IntlDateLocaleCode): Locale {
|
|
return locales[lang];
|
|
}
|