fix(core): Timestamp shows 'just now' for near-future clock skew#3174
Closed
durvesh1992 wants to merge 1 commit into
Closed
fix(core): Timestamp shows 'just now' for near-future clock skew#3174durvesh1992 wants to merge 1 commit into
durvesh1992 wants to merge 1 commit into
Conversation
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.
|
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. |
Contributor
Contributor
|
Thanks for this, @durvesh1992 — and your clock-skew insight made it in. #3099 was just fixed on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #3099.
When a
Timestampvalue is set to the current time but the component's internalnowreference 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 ingetRelativeTimeString.Testing
pnpm -F @astryxdesign/core test Timestamp— 25/25 pass (23 existing + 2 new).Changeset
Included (
@astryxdesign/corepatch).