Format time using dateLocale

This commit is contained in:
Harry Oosterveen 2025-02-14 20:08:17 +01:00
parent e34547cf2d
commit 0b8f251a2d

View file

@ -2,11 +2,13 @@ import { setItem } from 'next-basics';
import { TIMEZONE_CONFIG } from 'lib/constants';
import { formatInTimeZone, zonedTimeToUtc, utcToZonedTime } from 'date-fns-tz';
import useStore, { setTimezone } from 'store/app';
import useLocale from './useLocale';
const selector = (state: { timezone: string }) => state.timezone;
export function useTimezone() {
const timezone = useStore(selector);
const { dateLocale } = useLocale();
const saveTimezone = (value: string) => {
setItem(TIMEZONE_CONFIG, value);
@ -20,6 +22,7 @@ export function useTimezone() {
: date.split(' ').join('T') + 'Z',
timezone,
pattern,
{ locale: dateLocale },
);
};