update: fix invoice proccessor
This commit is contained in:
@@ -2,6 +2,20 @@ export function numberFormat(number: number, locale: string = "fa-IR") {
|
||||
return Intl.NumberFormat(locale).format(number);
|
||||
}
|
||||
|
||||
export function dateFormat(date: Date, locale: string = "fa-IR") {
|
||||
return new Intl.DateTimeFormat(locale).format(date);
|
||||
export function dateFormat(date: Date | string | number, locale: string = "fa-IR") {
|
||||
try {
|
||||
// Convert to Date object if it's a string or number
|
||||
const dateObj = date instanceof Date ? date : new Date(date);
|
||||
|
||||
// Check if the date is valid
|
||||
if (isNaN(dateObj.getTime())) {
|
||||
console.warn("Invalid date provided to dateFormat:", date);
|
||||
return "Invalid Date";
|
||||
}
|
||||
|
||||
return new Intl.DateTimeFormat(locale).format(dateObj);
|
||||
} catch (error) {
|
||||
console.error("Error formatting date:", error);
|
||||
return "Invalid Date";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user