fix registry employer Invalid time value
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m23s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m23s
This commit is contained in:
parent
1a9947d362
commit
17f7fc5d84
2 changed files with 12 additions and 1 deletions
|
|
@ -14,7 +14,10 @@ export class DateSerializer {
|
|||
|
||||
static setupDateSerialization() {
|
||||
// Override Date.prototype.toJSON to use local time
|
||||
Date.prototype.toJSON = function () {
|
||||
Date.prototype.toJSON = function (): any {
|
||||
// Check for Invalid Date - return null for invalid dates
|
||||
if (isNaN(this.getTime())) return null;
|
||||
|
||||
const offset = 7 * 60; // Thailand timezone offset in minutes
|
||||
const localTime = new Date(this.getTime() + offset * 60 * 1000);
|
||||
const isoString = localTime.toISOString();
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ class Extension {
|
|||
}
|
||||
|
||||
public static ToThaiFullDate(value: Date) {
|
||||
if (value == null || value == undefined || isNaN(value.getTime())) return "";
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return (
|
||||
"วันที่ " +
|
||||
|
|
@ -195,11 +196,13 @@ class Extension {
|
|||
);
|
||||
}
|
||||
public static ToThaiFullDate2(value: Date) {
|
||||
if (value == null || value == undefined || isNaN(value.getTime())) return "";
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return value.getDate() + " " + Extension.ToThaiMonth(value.getMonth() + 1) + " " + yy;
|
||||
}
|
||||
|
||||
public static ToThaiShortDate(value: Date) {
|
||||
if (value == null || value == undefined || isNaN(value.getTime())) return "";
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return (
|
||||
"วันที่ " +
|
||||
|
|
@ -212,6 +215,7 @@ class Extension {
|
|||
}
|
||||
|
||||
public static ToThaiShortDate_noPrefix(value: Date) {
|
||||
if (value == null || value == undefined || isNaN(value.getTime())) return "";
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return (
|
||||
value.getDate() +
|
||||
|
|
@ -223,6 +227,7 @@ class Extension {
|
|||
}
|
||||
|
||||
public static ToThaiShortDate_monthYear(value: Date) {
|
||||
if (value == null || value == undefined || isNaN(value.getTime())) return "";
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return (
|
||||
value.getDate() + " เดือน " + Extension.ToThaiMonth(value.getMonth() + 1) + " พ.ศ. " + yy
|
||||
|
|
@ -230,11 +235,13 @@ class Extension {
|
|||
}
|
||||
|
||||
public static ToThaiShortDate_monthYear2(value: Date) {
|
||||
if (value == null || value == undefined || isNaN(value.getTime())) return "";
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return value.getDate() + " " + Extension.ToThaiMonth(value.getMonth() + 1) + " พ.ศ. " + yy;
|
||||
}
|
||||
|
||||
public static ToThaiShortYear(value: Date) {
|
||||
if (value == null || value == undefined || isNaN(value.getTime())) return "";
|
||||
let yy = value.getFullYear() < 2400 ? value.getFullYear() + 543 : value.getFullYear();
|
||||
return yy.toString();
|
||||
}
|
||||
|
|
@ -394,6 +401,7 @@ class Extension {
|
|||
}
|
||||
|
||||
public static toDateOnlyString(date: Date): string {
|
||||
if (date == null || date == undefined || isNaN(date.getTime())) return "";
|
||||
return (
|
||||
date.getFullYear() +
|
||||
"-" +
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue