Skip to content

Commit

Permalink
Merge branch 'main' into 972-fix-mobile-menu-footer
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-aurele-besner authored Nov 19, 2024
2 parents f911407 + 361bcea commit b256b04
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions explorer/src/utils/time.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,14 @@ export const formatSeconds = (seconds: number | bigint): string => {
)
}

export const utcToLocalRelativeTime = (timestamp: string): string =>
dayjs.utc(timestamp).local().fromNow(true) + ' ago'
export const utcToLocalRelativeTime = (timestamp: string): string => {
const now = dayjs()
const time = dayjs.utc(timestamp).local()
const diffInSeconds = now.diff(time, 'second')

if (diffInSeconds < 60) return `${diffInSeconds} seconds ago`
return time.fromNow(true) + ' ago'
}

export const utcToLocalTime = (timestamp: string): string =>
dayjs.utc(timestamp).local().format('DD MMM YYYY | HH:mm:ss(Z)')
Expand Down

0 comments on commit b256b04

Please sign in to comment.