Feature/support localization in date fns (#1195)

* Add locale to date-fns (formatDistanceToNow)

* Update changelog
This commit is contained in:
Thomas Kaul
2022-08-27 10:54:59 +02:00
committed by GitHub
parent e757e90e5a
commit 2db46e5bbf
4 changed files with 19 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
import * as currencies from '@dinero.js/currencies';
import { DataSource } from '@prisma/client';
import { getDate, getMonth, getYear, parse, subDays } from 'date-fns';
import { de } from 'date-fns/locale';
import { ghostfolioScraperApiSymbolPrefix, locale } from './config';
import { Benchmark } from './interfaces';
@@ -56,6 +57,14 @@ export function getCssVariable(aCssVariable: string) {
);
}
export function getDateFnsLocale(aLanguageCode: string) {
if (aLanguageCode === 'de') {
return de;
}
return undefined;
}
export function getDateFormatString(aLocale?: string) {
const formatObject = new Intl.DateTimeFormat(aLocale).formatToParts(
new Date()