mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-27 04:45:54 +01:00
21 lines
519 B
JavaScript
21 lines
519 B
JavaScript
import { useState, useCallback } from 'react';
|
|
import { getTimezone } from 'lib/date';
|
|
import { getItem, setItem } from 'next-basics';
|
|
import { TIMEZONE_CONFIG } from 'lib/constants';
|
|
|
|
export function useTimezone() {
|
|
const [timezone, setTimezone] = useState(getItem(TIMEZONE_CONFIG) || getTimezone());
|
|
|
|
const saveTimezone = useCallback(
|
|
value => {
|
|
setItem(TIMEZONE_CONFIG, value);
|
|
setTimezone(value);
|
|
},
|
|
[setTimezone],
|
|
);
|
|
|
|
return [timezone, saveTimezone];
|
|
}
|
|
|
|
export default useTimezone;
|