เเก้ให้ปี ต่ำสุด คศ 0001

This commit is contained in:
setthawutttty 2023-09-20 15:27:03 +07:00
parent 270808981f
commit fe672a5aff
2 changed files with 8 additions and 18 deletions

View file

@ -129,7 +129,7 @@ const close = async () => {
}; };
</script> </script>
<template> <template>
<q-dialog v-model="props.Modal"> <q-dialog v-model="props.Modal" persistent>
<q-card style="max-width: 100%; width: 80%"> <q-card style="max-width: 100%; width: 80%">
<q-form ref="myForm"> <q-form ref="myForm">
<div class="row"> <div class="row">

View file

@ -76,13 +76,12 @@ export const useCounterMixin = defineStore("mixin", () => {
) { ) {
if (srcDate == null) { if (srcDate == null) {
return null; return null;
`
`;
} }
const date = new Date(srcDate); const date = new Date(srcDate);
const isValidDate = Boolean(+date); const isValidDate = Boolean(+date);
if (!isValidDate) return srcDate.toString(); if (!isValidDate) return srcDate.toString();
if (isValidDate && date.getFullYear() < 1000) return srcDate.toString();
const fullMonthThai = [ const fullMonthThai = [
"มกราคม", "มกราคม",
"กุมภาพันธ์", "กุมภาพันธ์",
@ -111,26 +110,17 @@ export const useCounterMixin = defineStore("mixin", () => {
"พ.ย.", "พ.ย.",
"ธ.ค.", "ธ.ค.",
]; ];
let dstYear = 0;
if (date.getFullYear() > 2500) { let dstYear = date.getFullYear() < 1 ? "0001" : (date.getFullYear() + 543).toString();
dstYear = date.getFullYear(); let dstMonth = isFullMonth ? fullMonthThai[date.getMonth()] : abbrMonthThai[date.getMonth()];
} else {
dstYear = date.getFullYear() + 543;
}
let dstMonth = "";
if (isFullMonth) {
dstMonth = fullMonthThai[date.getMonth()];
} else {
dstMonth = abbrMonthThai[date.getMonth()];
}
let dstTime = ""; let dstTime = "";
if (isTime) { if (isTime) {
const H = date.getHours().toString().padStart(2, "0"); const H = date.getHours().toString().padStart(2, "0");
const M = date.getMinutes().toString().padStart(2, "0"); const M = date.getMinutes().toString().padStart(2, "0");
// const S = date.getSeconds().toString().padStart(2, "0")
// dstTime = " " + H + ":" + M + ":" + S + " น."
dstTime = " " + H + ":" + M + " น."; dstTime = " " + H + ":" + M + " น.";
} }
return ( return (
date.getDate().toString().padStart(2, "0") + date.getDate().toString().padStart(2, "0") +
" " + " " +