1 import { default as enGBLocale } from 'date-fns/locale/en-GB';
2 import { default as enUSLocale } from 'date-fns/locale/en-US';
3 import { default as faIRLocale } from 'date-fns/locale/fa-IR';
5 import type { DateFnsLocaleMap } from '../interfaces/Locale';
7 const dateFnLocales = import.meta.webpackContext!('date-fns/locale', {
9 regExp: /^\.\/[a-z]{2}(-([A-Z]{2}))?\/index\.js$/,
11 chunkName: 'date-fns/[request]',
14 const dateFnsLocaleMap = dateFnLocales.keys().reduce((acc: DateFnsLocaleMap, key: string) => {
15 const end = key.lastIndexOf('/');
16 const normalizedKey = key.slice(2, end).replace('-', '_');
17 acc[normalizedKey] = () => dateFnLocales(key);
21 export { enUSLocale };
22 export { enGBLocale };
23 export { faIRLocale };
25 export const getDateFnLocale = (value: string) => {
26 if (value === 'en_US') {
29 if (value === 'en_GB') {
32 if (value === 'fa_IR') {
35 return dateFnsLocaleMap[value]();
38 export default dateFnsLocaleMap;