mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Format time using dateLocale
This commit is contained in:
parent
e34547cf2d
commit
0b8f251a2d
1 changed files with 3 additions and 0 deletions
|
|
@ -2,11 +2,13 @@ import { setItem } from 'next-basics';
|
||||||
import { TIMEZONE_CONFIG } from 'lib/constants';
|
import { TIMEZONE_CONFIG } from 'lib/constants';
|
||||||
import { formatInTimeZone, zonedTimeToUtc, utcToZonedTime } from 'date-fns-tz';
|
import { formatInTimeZone, zonedTimeToUtc, utcToZonedTime } from 'date-fns-tz';
|
||||||
import useStore, { setTimezone } from 'store/app';
|
import useStore, { setTimezone } from 'store/app';
|
||||||
|
import useLocale from './useLocale';
|
||||||
|
|
||||||
const selector = (state: { timezone: string }) => state.timezone;
|
const selector = (state: { timezone: string }) => state.timezone;
|
||||||
|
|
||||||
export function useTimezone() {
|
export function useTimezone() {
|
||||||
const timezone = useStore(selector);
|
const timezone = useStore(selector);
|
||||||
|
const { dateLocale } = useLocale();
|
||||||
|
|
||||||
const saveTimezone = (value: string) => {
|
const saveTimezone = (value: string) => {
|
||||||
setItem(TIMEZONE_CONFIG, value);
|
setItem(TIMEZONE_CONFIG, value);
|
||||||
|
|
@ -20,6 +22,7 @@ export function useTimezone() {
|
||||||
: date.split(' ').join('T') + 'Z',
|
: date.split(' ').join('T') + 'Z',
|
||||||
timezone,
|
timezone,
|
||||||
pattern,
|
pattern,
|
||||||
|
{ locale: dateLocale },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue