-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix property type 'date' when backend returns an iso string
- Loading branch information
Showing
3 changed files
with
22 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/frontend/components/property-type/datetime/strip-time-from-iso.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const stripTimeFromISO = (date: string | Date | null): string | null => { | ||
if (date === null) return null | ||
|
||
if (typeof date === 'string') { | ||
return date.replace(/T\d{2}:\d{2}:\d{2}\.\d{3}Z$/, '') | ||
} | ||
|
||
return date.toISOString().replace(/T\d{2}:\d{2}:\d{2}\.\d{3}Z$/, '') | ||
} |