replace getDate with toIsoString().slice(0,10) (#3792)

zio/stable
Samuel Newman 2024-05-01 15:50:30 +01:00 committed by GitHub
parent 80a1687dae
commit a6061489ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -108,18 +108,22 @@ function Metadata({
const diff = now.getTime() - date.getTime() const diff = now.getTime() - date.getTime()
// under 1 minute // if under 1 minute
if (diff < 1000 * 60) { if (diff < 1000 * 60) {
return _(msg`Now`) return _(msg`Now`)
} }
// in the last day // if in the last day
if (now.getDate() === date.getDate()) { if (now.toISOString().slice(0, 10) === date.toISOString().slice(0, 10)) {
return time return time
} }
// if yesterday // if yesterday
if (diff < 24 * 60 * 60 * 1000 && now.getDate() - date.getDate() === 1) { const yesterday = new Date(now)
yesterday.setDate(yesterday.getDate() - 1)
if (
yesterday.toISOString().slice(0, 10) === date.toISOString().slice(0, 10)
) {
return _(msg`Yesterday, ${time}`) return _(msg`Yesterday, ${time}`)
} }