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

Open
#1,425 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@MuhammadFaizan-prog is already working on this.

Since Nov 14, 2026.

  • #1426 by @MuhammadFaizan-prog — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript
Domain
frontend

Research direction

Read timeAgo in packages/markups/src/elements/TimestampElement.js; the seconds-through-weeks branches are correct, so focus on the months and years branches that subtract only getMonth() / getFullYear() and lose the sign. Run the existing markup tests for TimestampElement with the four examples from the issue (36 days, 13 months, exactly 2 years, 66 days future) to confirm the failures before changing the elapsed-month calculation and rounding. Note that pull request #1426 is already open against this issue, so check its state before starting.

Written by the indexing model from the issue text.

Description

bug
Description:

Relative timestamp markup (<t:UNIX:R>) is rendered by timeAgo in packages/markups/src/elements/TimestampElement.js. Seconds through weeks are derived from the elapsed time, but months and years are computed by subtracting only the calendar month and year numbers (getMonth() / getFullYear()). Once a timestamp is 4+ weeks away, the result ignores the year and gets the wrong sign across New Year:

  • 36 days ago (Dec 20 viewed on Jan 25) → "in 11 months"
  • 13 months ago → "1 month ago"
  • exactly 2 years ago (same calendar month) → "in 0 months"
  • 66 days in the future (Jan 20 viewed on Nov 15) → "10 months ago"
Steps to reproduce:
  1. During November 2026, send a message containing <t:1731672000:R> (Nov 15 2024).
  2. Send <t:1760529600:R> (Oct 15 2025) and <t:1768867200:R> (Jan 20 2027).
  3. Look at the rendered timestamps in EmbeddedChat.
Expected behavior:

"2 years ago", "1 year ago" and "in 2 months".

Actual behavior:

"in 0 months", "1 month ago" and "10 months ago".

Dominant language
JavaScript
Stars
170
Forks
397
Avg merge
12d 14h
Merged PRs (30d)
6

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from RocketChat/EmbeddedChat

All issues in RocketChat/EmbeddedChat

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.