refactor: standardized date format throughout the platform (#1461)

This commit is contained in:
Anmol Singh Bhatia 2023-07-04 18:19:19 +05:30 committed by GitHub
parent 5a6fd0efdb
commit 4ede04d72f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 48 additions and 35 deletions

View file

@ -114,7 +114,7 @@ export const getDateRangeStatus = (
}
};
export const renderShortDateWithYearFormat = (date: string | Date) => {
export const renderShortDateWithYearFormat = (date: string | Date, placeholder?: string) => {
if (!date || date === "") return null;
date = new Date(date);
@ -136,7 +136,8 @@ export const renderShortDateWithYearFormat = (date: string | Date) => {
const day = date.getDate();
const month = months[date.getMonth()];
const year = date.getFullYear();
return isNaN(date.getTime()) ? "N/A" : ` ${month} ${day}, ${year}`;
return isNaN(date.getTime()) ? placeholder ?? "N/A" : ` ${month} ${day}, ${year}`;
};
export const renderShortDate = (date: string | Date, placeholder?: string) => {