fix(frontend): show local date in history cards (matches displayed time)#720
Open
Osamaali313 wants to merge 1 commit into
Open
fix(frontend): show local date in history cards (matches displayed time)#720Osamaali313 wants to merge 1 commit into
Osamaali313 wants to merge 1 commit into
Conversation
HistoryDatabase.vue formatDate() derived the day from UTC (new Date(dateStr).toISOString().slice(0, 10)) while the sibling formatTime() uses local hours/minutes. The backend sends naive-local timestamps (datetime.now().isoformat()), so for any non-UTC client the two disagree by up to a day -- e.g. for the project's UTC+8 audience a record created 00:00-08:00 local shows the previous day's date next to the current time. Derive the date from local components so it matches the time shown.
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
In
frontend/src/components/HistoryDatabase.vue, the history card's date and time are derived from different time zones, so they can disagree by up to a day.created_atis a naive-local timestamp (datetime.now().isoformat()), returned verbatim by the history API.new Date("2026-07-08T01:00:00")is parsed as local;formatTimeshows the local clock, butformatDate'stoISOString()converts to UTC first. For any non-UTC client the day can shift — e.g. for the project's UTC+8 audience, a record created between 00:00 and 08:00 local shows yesterday's date next to today's time.Fix
Derive the date from local components, matching
formatTime:Verification
Extracted both helpers and ran them under Node on a UTC+3 machine with the naive timestamp
2026-07-08T01:00:00:formatTime→01:00(local, July 8)formatDate→2026-07-07(UTC) — wrong dayformatDate→2026-07-08— matches the time shownUnder
TZ=UTCthe discrepancy disappears in both versions, confirming the time zone was the sole cause. (No frontend test suite exists; happy to add a vitest case if you set one up.)