Skip to content

fix(markups): compute relative timestamp months and years from elapsed time - #1426

Open
MuhammadFaizan-prog wants to merge 1 commit into
RocketChat:developfrom
MuhammadFaizan-prog:fix/timestamp-relative-months
Open

MuhammadFaizan-prog wants to merge 1 commit into
RocketChat:developfrom
MuhammadFaizan-prog:fix/timestamp-relative-months

Conversation

@MuhammadFaizan-prog

Copy link
Copy Markdown

fix(markups): compute relative timestamp months and years from elapsed time

Acceptance Criteria fulfillment

  • <t:UNIX:R> timestamps older/newer than ~4 weeks show the correct direction (past = "ago", future = "in …")
  • Month and year values account for the full elapsed time, including across year boundaries (no more "in 0 months" for a date 2 years ago)
  • Seconds/minutes/hours/days/weeks output is unchanged

Fixes #1425

timeAgo in packages/markups/src/elements/TimestampElement.js derived seconds through weeks from the elapsed time, but months and years from getMonth()/getFullYear() differences only. This PR derives them from the same elapsed day count (days / 30, days / 365), a 2-line change with no API change.

Before → after (fixed "now" for each case):

Case Before After
36 days ago, across New Year in 11 months 1 month ago
13 months ago 1 month ago 1 year ago
26 days ago, same month in 0 months 1 month ago
66 days ahead, across New Year 10 months ago in 2 months
2 years ago, same month in 0 months 2 years ago
3 days ago (control) 3 days ago 3 days ago

Video/Screenshots

No UI screenshots: I don't have a live Rocket.Chat server here. The table above comes from evaluating the real timeAgo with a mocked clock.

PR Test Details

Prepared with AI assistance (Hark); I reviewed and own the final diff.

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-<pr_number> after approval. Contributors are requested to replace <pr_number> with the actual PR number.

This branch has not been deployed

No deployments
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.

Relative timestamps (<t:…:R>) show wrong direction and size past ~4 weeks ("in 0 months" for a date 2 years ago)

1 participant