Skip to content

Commit

Permalink
Fixed date time format for edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Aug 9, 2024
1 parent f5721b9 commit ef27a1c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ const formatValue = (value: unknown, key?: string): ReactNode => {
return trimmed;
}

if (new Date(trimmed).toString() !== "Invalid Date") {
const dateTimeRegex =
/^\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})?)?$/;

if (trimmed.match(dateTimeRegex)) {
return new Date(trimmed).toLocaleString();
}

Expand Down

0 comments on commit ef27a1c

Please sign in to comment.