fix bug dateToISO in mixin

This commit is contained in:
Warunee Tamkoo 2023-09-22 17:44:28 +07:00
parent 32a68116dc
commit 792ea7ef33

View file

@ -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 ""
}
}