Preview mentions (#5571)

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Apoorv Mishra
2023-07-22 21:43:09 +05:30
committed by GitHub
parent dbd85d62cb
commit 5d71398ea6
27 changed files with 923 additions and 361 deletions

View File

@@ -1,4 +1,24 @@
/* eslint-disable import/no-duplicates */
import { subDays, subMonths, subWeeks, subYears } from "date-fns";
import {
de,
enUS,
es,
faIR,
fr,
it,
ja,
ko,
nl,
ptBR,
pt,
pl,
ru,
tr,
vi,
zhCN,
zhTW,
} from "date-fns/locale";
import type { DateFilter } from "../types";
export function subtractDate(date: Date, period: DateFilter) {
@@ -80,3 +100,35 @@ export function getCurrentDateTimeAsString(locales?: Intl.LocalesArgument) {
minute: "numeric",
});
}
const locales = {
de_DE: de,
en_US: enUS,
es_ES: es,
fa_IR: faIR,
fr_FR: fr,
it_IT: it,
ja_JP: ja,
ko_KR: ko,
nl_NL: nl,
pt_BR: ptBR,
pt_PT: pt,
pl_PL: pl,
ru_RU: ru,
tr_TR: tr,
vi_VN: vi,
zh_CN: zhCN,
zh_TW: zhTW,
};
/**
* Returns the date-fns locale object for the given user language preference.
*
* @param language The user language
* @returns The date-fns locale.
*/
export function dateLocale(language: string | null | undefined) {
return language ? locales[language] : undefined;
}
export { locales };