diff options
| author | zyoshoka <107108195+zyoshoka@users.noreply.github.com> | 2024-04-07 21:14:13 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-07 21:14:13 +0900 |
| commit | 959cc8ff37de620bf0082f48f59963c00d045fe9 (patch) | |
| tree | d1e98d9d4ac77f89fe3d8812a158c7ee997f8596 /packages/frontend/src | |
| parent | fix(deps): aiscript-vscodeのインストール中にWARNが出るのを修... (diff) | |
| download | sharkey-959cc8ff37de620bf0082f48f59963c00d045fe9.tar.gz sharkey-959cc8ff37de620bf0082f48f59963c00d045fe9.tar.bz2 sharkey-959cc8ff37de620bf0082f48f59963c00d045fe9.zip | |
refactor(general): use `Date.now()` instead of creating a new `Date` instance (#13671)
Diffstat (limited to 'packages/frontend/src')
| -rw-r--r-- | packages/frontend/src/components/global/MkTime.vue | 4 | ||||
| -rw-r--r-- | packages/frontend/src/widgets/WidgetUnixClock.vue | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/packages/frontend/src/components/global/MkTime.vue b/packages/frontend/src/components/global/MkTime.vue index 67532268d3..23fe99bd9c 100644 --- a/packages/frontend/src/components/global/MkTime.vue +++ b/packages/frontend/src/components/global/MkTime.vue @@ -47,7 +47,7 @@ const invalid = Number.isNaN(_time); const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid; // eslint-disable-next-line vue/no-setup-props-destructure -const now = ref((props.origin ?? new Date()).getTime()); +const now = ref(props.origin?.getTime() ?? Date.now()); const ago = computed(() => (now.value - _time) / 1000/*ms*/); const relative = computed<string>(() => { @@ -77,7 +77,7 @@ let tickId: number; let currentInterval: number; function tick() { - now.value = (new Date()).getTime(); + now.value = Date.now(); const nextInterval = ago.value < 60 ? 10000 : ago.value < 3600 ? 60000 : 180000; if (currentInterval !== nextInterval) { diff --git a/packages/frontend/src/widgets/WidgetUnixClock.vue b/packages/frontend/src/widgets/WidgetUnixClock.vue index 2ac7d1c781..832cd575cc 100644 --- a/packages/frontend/src/widgets/WidgetUnixClock.vue +++ b/packages/frontend/src/widgets/WidgetUnixClock.vue @@ -68,9 +68,9 @@ watch(showColon, (v) => { }); const tick = () => { - const now = new Date(); - ss.value = Math.floor(now.getTime() / 1000).toString(); - ms.value = Math.floor(now.getTime() % 1000 / 10).toString().padStart(2, '0'); + const now = Date.now(); + ss.value = Math.floor(now / 1000).toString(); + ms.value = Math.floor(now % 1000 / 10).toString().padStart(2, '0'); if (ss.value !== prevSec) showColon.value = true; prevSec = ss.value; }; |