เปลี่ยน function date

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-04-04 17:49:12 +07:00
parent 54c48e637d
commit 2073f9ab8c

View file

@ -5,7 +5,6 @@ import { useQuasar } from "quasar";
import http from "@/plugins/http"; import http from "@/plugins/http";
import config from "@/app.config"; import config from "@/app.config";
import type { FormFollowOther } from "@/modules/15_development/interface/request/Main";
import type { DataOption } from "@/modules/15_development/interface/index/Main"; import type { DataOption } from "@/modules/15_development/interface/index/Main";
import { useCounterMixin } from "@/stores/mixin"; import { useCounterMixin } from "@/stores/mixin";
@ -13,13 +12,8 @@ import { useDevelopmentDataStore } from "@/modules/15_development/store/developm
const $q = useQuasar(); const $q = useQuasar();
const store = useDevelopmentDataStore(); const store = useDevelopmentDataStore();
const { const { showLoader, hideLoader, diffDay, date2Thai, messageError } =
showLoader, useCounterMixin();
hideLoader,
calculateDurationYmd,
date2Thai,
messageError,
} = useCounterMixin();
const provinceOp = ref<DataOption[]>([]); const provinceOp = ref<DataOption[]>([]);
const provinceOpMain = ref<DataOption[]>([]); const provinceOpMain = ref<DataOption[]>([]);
@ -70,7 +64,7 @@ function changeDateStart() {
store.formAddProject.dateEnd = null; store.formAddProject.dateEnd = null;
store.formAddProject.totalDate = null; store.formAddProject.totalDate = null;
} else { } else {
daysBetweenDates( store.formAddProject.totalDate = diffDay(
store.formAddProject.dateStart, store.formAddProject.dateStart,
store.formAddProject.dateEnd store.formAddProject.dateEnd
); );
@ -79,35 +73,12 @@ function changeDateStart() {
} }
function changeDateEnd() { function changeDateEnd() {
daysBetweenDates( store.formAddProject.totalDate = diffDay(
store.formAddProject.dateStart, store.formAddProject.dateStart,
store.formAddProject.dateEnd store.formAddProject.dateEnd
); );
} }
async function daysBetweenDates(date1: any, date2: any) {
const newStartDate = resetTimeToMidnight(new Date(date1));
const newEndDate = resetTimeToMidnight(new Date(date2));
const differenceInMilliseconds =
newEndDate.getTime() - newStartDate.getTime();
const differenceInDays = Math.floor(
differenceInMilliseconds / (1000 * 60 * 60 * 24)
);
store.formAddProject.totalDate = differenceInDays + 1;
}
function resetTimeToMidnight(date: Date): Date {
const newDate = new Date(date);
newDate.setHours(0);
newDate.setMinutes(0);
newDate.setSeconds(0);
newDate.setMilliseconds(0);
return newDate;
}
/** /**
* Fuction Filter งหว * Fuction Filter งหว
* @param val าตวพมพนหา * @param val าตวพมพนหา