From 07c782950a848b9f452583cc01f72bc45ea84205 Mon Sep 17 00:00:00 2001 From: waruneeta Date: Mon, 12 Feb 2024 18:06:23 +0700 Subject: [PATCH] function convertdate --- src/stores/mixin.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/stores/mixin.ts b/src/stores/mixin.ts index e86afb1be..71fad33cd 100644 --- a/src/stores/mixin.ts +++ b/src/stores/mixin.ts @@ -304,6 +304,22 @@ export const useCounterMixin = defineStore("mixin", () => { } } + function convertDate(date: string) { + if (date != null && date.length == 10) { + const srcDate = date.split("/"); + const dateVal = + Number(srcDate[2]) - 543 + "-" + srcDate[1] + "-" + srcDate[0]; + + if (moment(dateVal).isValid()) { + return dateVal; + } else { + return "" + } + } else { + return ""; + } + } + function appendLeadingZeroes(n: number) { if (n <= 9) return "0" + n; return n; @@ -956,5 +972,6 @@ export const useCounterMixin = defineStore("mixin", () => { dialogRemove, dialogMessageNotify, fails, + convertDate, }; });