refactor(date): function convertDateToAPI delete utcToZonedTime Asia/Bangkok

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2026-05-06 17:46:04 +07:00
parent e54d936b19
commit 780a815a24

View file

@ -14,7 +14,7 @@ export const useCounterMixin = defineStore("mixin", () => {
const calAge = (
srcDate: Date,
birthCal: Date = new Date(),
eng: boolean = false
eng: boolean = false,
) => {
const year = eng ? "years" : "ปี";
const month = eng ? "months" : "เดือน";
@ -82,7 +82,7 @@ export const useCounterMixin = defineStore("mixin", () => {
function date2Thai(
srcDate: Date | null,
isFullMonth: boolean = false,
isTime: boolean = false
isTime: boolean = false,
) {
if (srcDate == null || !moment(srcDate).isValid()) return "";
@ -98,7 +98,7 @@ export const useCounterMixin = defineStore("mixin", () => {
function dateThai(
srcDate: Date,
isFullMonth: boolean = true,
isTime: boolean = false
isTime: boolean = false,
) {
if (srcDate == null) {
return null;
@ -490,7 +490,7 @@ export const useCounterMixin = defineStore("mixin", () => {
color: string | undefined,
ok?: Function | undefined,
cancel?: Function | undefined,
onlycancel: Boolean = false
onlycancel: Boolean = false,
) => {
q.dialog({
component: CustomComponent,
@ -529,7 +529,7 @@ export const useCounterMixin = defineStore("mixin", () => {
title: string,
message: string,
ok: Function,
cancel?: Function
cancel?: Function,
) {
q.dialog({
title: `<span class="text-red">${title}</span>`,
@ -559,7 +559,7 @@ export const useCounterMixin = defineStore("mixin", () => {
title: string,
message: string,
ok: Function,
cancel?: Function
cancel?: Function,
) {
q.dialog({
title: `<span class="text-primary">${title}</span>`,
@ -795,7 +795,7 @@ export const useCounterMixin = defineStore("mixin", () => {
ok?: Function,
title?: string, // ถ้ามี cancel action ใส่เป็น null
desc?: string, // ถ้ามี cancel action ใส่เป็น null
cancel?: Function
cancel?: Function,
) => {
q.dialog({
component: CustomComponent,
@ -824,7 +824,7 @@ export const useCounterMixin = defineStore("mixin", () => {
ok?: Function,
title?: string, // ถ้ามี cancel action ใส่เป็น null
desc?: string, // ถ้ามี cancel action ใส่เป็น null
cancel?: Function
cancel?: Function,
) => {
q.dialog({
component: CustomComponent,
@ -851,7 +851,7 @@ export const useCounterMixin = defineStore("mixin", () => {
const dialogMessageNotify = (
q: any,
desc?: string, // ถ้ามี cancel action ใส่เป็น null
cancel?: Function
cancel?: Function,
) => {
q.dialog({
component: CustomComponent,
@ -973,7 +973,7 @@ export const useCounterMixin = defineStore("mixin", () => {
* @returns 1 10 5
*/
function calculateDurationYmd(startDate: any, endDate: any) {
if (!startDate || !endDate) return "";
if (!startDate || !endDate) return "";
let start = moment(startDate).startOf("day");
let end = moment(endDate).startOf("day").add(1, "day");
@ -1252,9 +1252,7 @@ export const useCounterMixin = defineStore("mixin", () => {
// กรณีมีเฉพาะ date
function convertDateToAPI(date: Date | null) {
return date
? format(utcToZonedTime(date, "Asia/Bangkok"), "yyyy-MM-dd")
: null;
return date ? format(date, "yyyy-MM-dd") : null;
}
// กรณี datetime