From 792ea7ef333a50b619260d45914cb2968ffa5006 Mon Sep 17 00:00:00 2001 From: waruneeta Date: Fri, 22 Sep 2023 17:44:28 +0700 Subject: [PATCH] fix bug dateToISO in mixin --- src/stores/mixin.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index f3e429f4f..39f2edea5 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -244,16 +244,18 @@ export const useCounterMixin = defineStore("mixin", () => { } function dateToISO(date: Date) { - const isValidDate = Boolean(+date); - if (!isValidDate) return null; - if (isValidDate && date.getFullYear() < 1000) { + if (date != null) { + const srcDate = new Date(date) + return ( - date.getFullYear() + + srcDate.getFullYear() + "-" + - appendLeadingZeroes(date.getMonth() + 1) + + appendLeadingZeroes(srcDate.getMonth() + 1) + "-" + - appendLeadingZeroes(date.getDate()) + appendLeadingZeroes(srcDate.getDate()) ); + } else { + return "" } }