Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
ywwenjin163
pushed a commit
to ywwenjin163/open-seo
that referenced
this pull request
Sep 12, 2026
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.
Problem
Backlink history dates render one day early for every reader west of UTC, and the month axis one
month early on the 1st.
formatCompactDateandformatMonthLabelparse withnew Date(value). For a date-only string thatis UTC midnight, and
toLocaleDateStringthen renders it in the reader's own timezone:The values reaching these are calendar dates rather than instants, and the server makes them so
deliberately —
normalizeHistoryDateisvalue.slice(0, 10), applied to every history date. Therepo's own fixture is
date: "2026-02-01".So on the backlinks page, in the Americas:
firstSeen/lastSeencolumns show the day before the day the link was first seen2026-03-01is labelled Feb 26Fix
parseDisplayDatereads a date-only value (YYYY-MM-DDorYYYY-MM) as a local calendar date andleaves anything carrying a time to
Date, where the offset is real and local rendering is correct.Both formatters go through it;
formatRelativeTimestampis untouched because it is given aninstant.
Tests
The assertion that matters does not depend on where it runs:
UTC midnight and local midnight are the same instant only in UTC, so this pins the behaviour
everywhere else. Against
main, on my machine (UTC+9):That difference is 32,400,000 ms — exactly nine hours.
Three describes, one invariant each: the date-only parse, that a value with a time is left alone,
and that each formatter shows the date it was given. I kept the existing
truncateMiddletests asthey were.
How I tested
Windows 11, Node 22, pnpm 10.30.1.
I did not run the whole suite or e2e; this is a leaf utility with no other callers than the two
formatters it serves.
One thing I noticed and did not change
truncateMiddleslices on UTF-16 code units, so a cut can land inside a surrogate pair and leave alone surrogate. I checked whether it is reachable and it is not: its only caller passes
extractUrlPath, which returnsURL.pathname, and that is always percent-encoded ASCII. Mentioningit rather than fixing it, since a fix would be speculative.