Skip to content

Fix relative time text (e.g "today ago")#53

Merged
retlehs merged 2 commits into
retlehs:mainfrom
GLobyNew:todayAgo
Jun 23, 2026
Merged

Fix relative time text (e.g "today ago")#53
retlehs merged 2 commits into
retlehs:mainfrom
GLobyNew:todayAgo

Conversation

@GLobyNew

Copy link
Copy Markdown
Contributor

I've encountered just registered domain and it looks like relativeTime doesn't handle today / tomorrow duration properly:

image

"today ago"

I've added two additional check for today and tomorrow and func plural(n int, unit string) string function.

P.S the %ss means literally unit string + 's'. Maybe it's a bit confusing, its not special format specifier :)

GLobyNew and others added 2 commits June 11, 2026 23:48
The previous logic bucketed by elapsed hours (<24h/<48h), so a timestamp
less than a day away but on a different calendar date could be mislabeled
(e.g. a row reading "2026-06-24  today"). Since dateRow prints the civil
date via t.Format("2006-01-02"), compare civil dates instead via a
zone-independent day index so the label always matches the visible date,
including timestamps with explicit offsets. Add a testable relativeTimeFrom
seam so the labels can be asserted deterministically.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@retlehs retlehs left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I pushed a small follow-up that bases the today/yesterday/tomorrow labels on the calendar date

@retlehs retlehs merged commit edbd6ea into retlehs:main Jun 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants