Make datetime parsing resilient to empty strings
This commit is contained in:
parent
73f423db68
commit
20fbcca862
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -41,7 +41,8 @@
|
||||
"WRHGZC",
|
||||
"wxyz",
|
||||
"zadd",
|
||||
"zrange"
|
||||
"zrange",
|
||||
"datetime"
|
||||
],
|
||||
"files.associations": {
|
||||
"*.css": "tailwindcss"
|
||||
|
||||
@ -21,7 +21,7 @@ export const formatDateForPostgres = (date: Date) =>
|
||||
const dateFromTimestamp = (timestamp?: AmbiguousTimestamp): Date =>
|
||||
typeof timestamp === 'number'
|
||||
? new Date(timestamp * 1000)
|
||||
: typeof timestamp === 'string'
|
||||
: typeof timestamp === 'string' && timestamp.trim().length > 0
|
||||
? /.+Z/i.test(timestamp)
|
||||
? new Date(timestamp)
|
||||
: new Date(`${timestamp}Z`)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user