feat: better performance for timezone
This commit is contained in:
parent
9e87928045
commit
d5979ed6c8
|
|
@ -21,18 +21,16 @@ export const newDayjs = (config?: ConfigType) => {
|
|||
|
||||
const SetTimezone: FC = () => {
|
||||
useEffect(() => {
|
||||
dayjs.utc = new Proxy(originalUtc, {
|
||||
apply(target, thisArg, args) {
|
||||
const result = target.apply(thisArg, args);
|
||||
dayjs.utc = (config?: ConfigType, format?: string, strict?: boolean) => {
|
||||
const result = originalUtc(config, format, strict);
|
||||
|
||||
// Attach `.local()` method to the returned Dayjs object
|
||||
result.local = function () {
|
||||
return result.tz(getTimezone());
|
||||
};
|
||||
// Attach `.local()` method to the returned Dayjs object
|
||||
result.local = function () {
|
||||
return result.tz(getTimezone());
|
||||
};
|
||||
|
||||
return result;
|
||||
},
|
||||
});
|
||||
return result;
|
||||
};
|
||||
if (localStorage.getItem('timezone')) {
|
||||
dayjs.tz.setDefault(getTimezone());
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue