diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index d6ee99b61..f3e429f4f 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -244,13 +244,17 @@ export const useCounterMixin = defineStore("mixin", () => { } function dateToISO(date: Date) { - return ( - date.getFullYear() + - "-" + - appendLeadingZeroes(date.getMonth() + 1) + - "-" + - appendLeadingZeroes(date.getDate()) - ); + const isValidDate = Boolean(+date); + if (!isValidDate) return null; + if (isValidDate && date.getFullYear() < 1000) { + return ( + date.getFullYear() + + "-" + + appendLeadingZeroes(date.getMonth() + 1) + + "-" + + appendLeadingZeroes(date.getDate()) + ); + } } function appendLeadingZeroes(n: number) {