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",
|
"WRHGZC",
|
||||||
"wxyz",
|
"wxyz",
|
||||||
"zadd",
|
"zadd",
|
||||||
"zrange"
|
"zrange",
|
||||||
|
"datetime"
|
||||||
],
|
],
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.css": "tailwindcss"
|
"*.css": "tailwindcss"
|
||||||
|
|||||||
@ -21,7 +21,7 @@ export const formatDateForPostgres = (date: Date) =>
|
|||||||
const dateFromTimestamp = (timestamp?: AmbiguousTimestamp): Date =>
|
const dateFromTimestamp = (timestamp?: AmbiguousTimestamp): Date =>
|
||||||
typeof timestamp === 'number'
|
typeof timestamp === 'number'
|
||||||
? new Date(timestamp * 1000)
|
? new Date(timestamp * 1000)
|
||||||
: typeof timestamp === 'string'
|
: typeof timestamp === 'string' && timestamp.trim().length > 0
|
||||||
? /.+Z/i.test(timestamp)
|
? /.+Z/i.test(timestamp)
|
||||||
? new Date(timestamp)
|
? new Date(timestamp)
|
||||||
: new Date(`${timestamp}Z`)
|
: new Date(`${timestamp}Z`)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user