New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(xo-web): Hide creation date if not available #3959
Conversation
@@ -54,12 +54,12 @@ function toTimestamp(date) { | |||
return timestamp | |||
} | |||
|
|||
const ms = parseDateTime(date) | |||
if (!ms) { | |||
const ms = parseDateTime(date).getTime() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if date
does not respect the expected format (%Y%m%dT%H:%M:%SZ
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have problem !
Cannot read property 'getTime' of null
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to handle this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just modified it. Better ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, at least it does not break anymore 🙂
@@ -55,7 +55,7 @@ function toTimestamp(date) { | |||
} | |||
|
|||
const ms = parseDateTime(date) | |||
if (!ms) { | |||
if (!ms || ms.getTime() === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ms
should contain milliseconds. So maybe something like that:
const ms = parseDateTime(date)?.getTime?.()
if (ms === undefined || ms === 0) {
return null
}
return Math.round(ms / 1000)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the second ?.
is unnecessary.
Also you can use the ternary operator instead of the if
statement.
b9647f8
to
c702647
Compare
Fixes #3953
Check list
Fixes #007
)CHANGELOG.unreleased.md
:${name} v${new version}
)Process
WiP:
(Work in Progress) if not ready to be merged