mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-18 23:33:37 +01:00
18 lines
447 B
JavaScript
18 lines
447 B
JavaScript
import { useState, useCallback } from 'react';
|
|
import { getTimezone } from 'lib/date';
|
|
import { getItem, setItem } from 'lib/web';
|
|
|
|
export default function useTimezone() {
|
|
const [timezone, setTimezone] = useState(getItem('umami.timezone') || getTimezone());
|
|
|
|
const saveTimezone = useCallback(
|
|
value => {
|
|
setItem('umami.timezone', value);
|
|
setTimezone(value);
|
|
},
|
|
[setTimezone],
|
|
);
|
|
|
|
return [timezone, saveTimezone];
|
|
}
|