Format time using dateLocale
This commit is contained in:
@@ -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 },
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user