Skip to content

fix(core): Timestamp shows 'just now' for near-future clock skew#3174

Closed
durvesh1992 wants to merge 1 commit into
facebook:mainfrom
durvesh1992:fix/timestamp-clock-skew-just-now
Closed

fix(core): Timestamp shows 'just now' for near-future clock skew#3174
durvesh1992 wants to merge 1 commit into
facebook:mainfrom
durvesh1992:fix/timestamp-clock-skew-just-now

Conversation

@durvesh1992

Copy link
Copy Markdown
Contributor

Summary

Closes #3099.

When a Timestamp value is set to the current time but the component's internal now reference lags the real clock, the diff goes slightly negative and the relative formatter returned "in a few seconds" for what is effectively the present. This is confusing in UIs that update a timestamp on an action (the reported repro: clicking an action that sets the timestamp to "right now").

Treat a value within a small clock-skew tolerance (CLOCK_SKEW_TOLERANCE = 30s) in the future as "just now". Genuine near-future times beyond the tolerance still render "in a few seconds", and all larger future ranges ("in 1 hour", etc.) are unchanged.

packages/core/src/Timestamp/Timestamp.tsx — add the tolerance constant and short-circuit in getRelativeTimeString.

Testing

  • pnpm -F @astryxdesign/core test Timestamp25/25 pass (23 existing + 2 new).
  • New tests: a value +5s in the future → "just now"; a value +45s → still "in a few seconds" (tolerance boundary preserved).

Changeset

Included (@astryxdesign/core patch).

Closes facebook#3099.

When a Timestamp's value is set to the current time but the component's
internal 'now' reference lags the real clock, the diff goes slightly
negative and the relative formatter returned 'in a few seconds' for what
is effectively the present — confusing in UIs that update a timestamp on
an action.

Treat a value within a small clock-skew tolerance (30s) in the future as
'just now'. Genuine near-future times beyond the tolerance still render
'in a few seconds'. Adds tests for both cases.
@vercel

vercel Bot commented Jun 26, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Meta Open Source Team on Vercel.

A member of the Team first needs to authorize it.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 26, 2026
@cixzhang

cixzhang commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Thanks for working on this. I got #3159 inflight but I like your increased time skew. Will merge some of this into #3159 and credit you :)

@cixzhang

Copy link
Copy Markdown
Contributor

Thanks for this, @durvesh1992 — and your clock-skew insight made it in. #3099 was just fixed on main via a parallel PR (#3159), and your idea of a wider future-side tolerance (~30s, since future drift is almost always skew) was folded into that fix, with you credited in the changeset. Closing this as a duplicate, but the core improvement is yours. 🙏

@cixzhang cixzhang closed this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Timestamp renders "in a few seconds" for current time

2 participants