We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1384e5d commit b114567Copy full SHA for b114567
frontend/src/utils/format.ts
@@ -18,6 +18,8 @@ export function formatRelativeTime(d: string | number) {
18
const now = Date.now()
19
const diffMs = date.getTime() - now
20
21
+ const isSameDay = formatDate(d, 'YYYY-MM-DD') === formatDate(now, 'YYYY-MM-DD')
22
+
23
// now
24
if (diffMs === 0) return formatter.format(0, 'second')
25
@@ -31,6 +33,7 @@ export function formatRelativeTime(d: string | number) {
31
33
]
32
34
35
for (const { unit, threshold } of units) {
36
+ if (unit === 'day' && isSameDay) continue
37
const amount = Math.round(diffMs / threshold)
38
if (Math.abs(amount) > 0) return formatter.format(amount, unit)
39
}
0 commit comments