Skip to content

Commit

Permalink
replace getDate with toIsoString().slice(0,10) (#3792)
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius authored May 1, 2024
1 parent 80a1687 commit a606148
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/screens/Messages/Conversation/MessageItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,22 @@ function Metadata({

const diff = now.getTime() - date.getTime()

// under 1 minute
// if under 1 minute
if (diff < 1000 * 60) {
return _(msg`Now`)
}

// in the last day
if (now.getDate() === date.getDate()) {
// if in the last day
if (now.toISOString().slice(0, 10) === date.toISOString().slice(0, 10)) {
return time
}

// 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}`)
}

Expand Down

0 comments on commit a606148

Please sign in to comment.