This commit is contained in:
Adisak 2025-10-02 14:37:25 +07:00
parent a45d3744e5
commit 4be0b068bc
5 changed files with 12 additions and 10 deletions

View file

@ -309,11 +309,13 @@ class Extension {
return years;
}
public static CalculateAgeStrV2(date: Date, plusYear: number = 0, subtractYear: number = 0) {
public static CalculateAgeStrV2(date: Date, plusYear: number = 0, subtractYear: number = 0, method?:string) {
if (date == null || date == undefined) return "";
const currentDate = new Date();
if (date > currentDate) {
if (date > currentDate && method !== "GET") {
throw new Error("วันเกิดต้องไม่มากกว่าวันที่ปัจจุบัน");
}else if(date > currentDate && method === "GET"){
return ""
}
let years = currentDate.getFullYear() - date.getFullYear();