Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 0 minutes ago and 0 hours ago timestamps #1611

Merged
merged 3 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions frontend/src/datetimeFormats.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,19 @@ export function formatRelative(date) {
const now = new Date()
const diff = Math.round((date - now) / 1000)
const absDiff = Math.abs(diff)
const sign = diff < 1 ? -1 : 1

if (absDiff < 90) {
return momentAgo
}

if (absDiff < 60 * 47) {
const minutes = Math.ceil(diff / 60)
const minutes = Math.ceil(absDiff / 60) * sign
return relativeNumeric.format(minutes, "minute")
}

if (absDiff < 3600 * 3) {
const hours = Math.ceil(diff / 3600)
const hours = Math.ceil(absDiff / 3600) * sign
return relativeNumeric.format(hours, "hour")
}

Expand Down
2 changes: 1 addition & 1 deletion misago/static/misago/js/misago.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion misago/static/misago/js/misago.js.map

Large diffs are not rendered by default.