mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Cleaned up language files.
This commit is contained in:
parent
33b87b41a9
commit
92b205b7b7
6 changed files with 50 additions and 94 deletions
10
lib/date.js
10
lib/date.js
|
|
@ -26,7 +26,7 @@ import {
|
|||
format,
|
||||
} from 'date-fns';
|
||||
import { enUS } from 'date-fns/locale';
|
||||
import { dateLocales } from 'lib/lang';
|
||||
import { languages } from 'lib/lang';
|
||||
|
||||
export function getTimezone() {
|
||||
return moment.tz.guess();
|
||||
|
|
@ -38,7 +38,7 @@ export function getLocalTime(t) {
|
|||
|
||||
export function getDateRange(value, locale = 'en-US') {
|
||||
const now = new Date();
|
||||
const localeOptions = dateLocales[locale];
|
||||
const dateLocale = languages[locale]?.dateLocale || enUS;
|
||||
|
||||
const { num, unit } = value.match(/^(?<num>[0-9]+)(?<unit>hour|day|week|month|year)$/).groups;
|
||||
|
||||
|
|
@ -53,8 +53,8 @@ export function getDateRange(value, locale = 'en-US') {
|
|||
};
|
||||
case 'week':
|
||||
return {
|
||||
startDate: startOfWeek(now, { locale: localeOptions }),
|
||||
endDate: endOfWeek(now, { locale: localeOptions }),
|
||||
startDate: startOfWeek(now, { locale: dateLocale }),
|
||||
endDate: endOfWeek(now, { locale: dateLocale }),
|
||||
unit: 'day',
|
||||
value,
|
||||
};
|
||||
|
|
@ -164,6 +164,6 @@ export const customFormats = {
|
|||
|
||||
export function dateFormat(date, str, locale = 'en-US') {
|
||||
return format(date, customFormats?.[locale]?.[str] || str, {
|
||||
locale: dateLocales[locale] || enUS,
|
||||
locale: languages[locale]?.dateLocale || enUS,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue