Skip to content

Commit

Permalink
fix bug with dates within 24h
Browse files Browse the repository at this point in the history
  • Loading branch information
amendelsohn committed Jul 29, 2024
1 parent bc5d497 commit 819562f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/common/src/utils/formatUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,11 +281,13 @@ export const formatReleaseDate = ({
const releaseDate = dayjs(date)
const now = dayjs()

// Can't use daysDifference === 0 because anything under 24 hours counts
const isToday = releaseDate.isSame(now, 'day')
const daysDifference = releaseDate.diff(now, 'days')

if (daysDifference >= 0 && daysDifference < 7) {
return (
`${daysDifference === 0 ? 'Today' : releaseDate.format('dddd')}` +
`${isToday ? 'Today' : releaseDate.format('dddd')}` +
(withHour ? ` @ ${releaseDate.format('h A')}` : '')
)
} else {
Expand Down

0 comments on commit 819562f

Please sign in to comment.