Repository navigation
fix(arc): render calendar dates in UTC so weekday labels stop shifting - #99
Merged
Merged
Conversation
- Introduced a new function `parseIsoDateUtc` to parse calendar dates in the format `YYYY-MM-DD` as UTC instants for consistent display formatting. - This function ensures that dates are interpreted in UTC, preventing local time zone discrepancies during rendering.
- Added unit tests for the new `parseIsoDateUtc` function to verify correct UTC parsing and weekday retention. - Created a new test file for the `arc` module, implementing tests for the `buildArcModel` function, ensuring proper week structure, today marker, and log placement. - Enhanced test coverage for date handling and ritual logging functionality.
- Renamed views in the documentation for clarity: `v_ritual_progress` to `ritual_progress`, `v_daily_summary` to `daily_summary`, and `v_ritual_log_history` to `ritual_log_history`. - Improved formatting for better readability.
…ponents to use parseIsoDateUtc for consistent UTC formatting - Updated date parsing in RhythmDayBar and OneTimeStatus components to utilize the new parseIsoDateUtc function, ensuring dates are correctly interpreted as UTC. - Removed the local date conversion function from TheArc component and replaced it with parseIsoDateUtc for better consistency in date formatting across the application. - Enhanced date display logic to include time zone specification, preventing discrepancies in date representation.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Strive PR Agent ReviewThe review could not be generated for this run (model unavailable or rate-limited). Push again to retry. |
5 tasks done
This branch was successfully deployed
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
On the ritual detail page, The Arc's week strip read
SUN MON TUE ... SATwith theheader
WEEK OF SEP 13, and logs made on Tuesday, Thursday and Saturday appearedunder Monday, Wednesday and Friday.
The week was never Sunday-first and the data was never wrong: every label was
rendered one day early, which makes a Monday-first row look Sunday-first.
Cause
i18n.tsdoes not settimeZone, so next-intl falls back to the server's zone(
getConfig.js:timeZone: o.timeZone || Intl.DateTimeFormat().resolvedOptions().timeZone)and forwards it to
NextIntlClientProvider- UTC in production.the-arc.tsxparsed calendar dates without aZ:Per ECMAScript that is parsed in the runtime's zone.
TheArcis a ClientComponent, so that runtime is the browser: in Europe/Paris
2026-09-14T00:00:00is
2026-09-13T22:00:00Z, which the UTC formatter renders as Sep 13.Reproduced across zones (before -> after), formatter pinned to UTC:
Only browsers east of UTC were affected, which is why it looked intermittent.
Fix
Add
parseIsoDateUtctolib/date.tsand pair it withtimeZone: "UTC"at everycalendar-date display. Both halves are required: parsing in UTC without pinning the
formatter just moves the bug. This generalizes the convention already applied
locally in
circles/[id]/page.tsx.One change fixes all four shifted strings in The Arc: the day letters, the
WEEK OFheader, the chart axis endpoints and the week-select aria-label.rhythm-day-bar.tsxandone-time-status.tsxuse the same pattern and are correcttoday only because they render on the server, where both zones resolve to the same
value. Aligned for consistency; no behavior change.
relDaysis untouched:relativeTimeignorestimeZoneand itsT12:00:00parse is a deliberate DST guard.Tests
lib/rituals/arc.test.tsis new -arc.tswas pure but untested. It locks the datacontract this bug hid: weeks run Monday to Sunday,
isTodayis marked exactly onceat its Monday-based index, and Tue/Thu/Sat logs land at indices 1/3/5.
83 tests pass (76 + 7).
lint,tsc --noEmitandbuildclean.No i18n keys, no color tokens, no copy change.
Also in this PR
data/README.mddocumented the views asv_ritual_progress,v_daily_summaryandv_ritual_log_history. That prefix never existed - the real views areritual_progress,daily_summaryandritual_log_history, asmigrate.pyandlib/data/rituals.tshave always used them.Follow-up (not in this PR)
getUserToday(lib/profile.ts) readsprofiles.timezonewithout.eq("id", user.id).Since
profilesis world-readable (for select using (true)), the query matches everyrow, and
maybeSingle()returnsdata = nullplus a discarded PGRST116 error - so everyuser silently falls back to
'UTC'. Between 00:00 and 02:00 Paris time that makes"today" yesterday, including the
logged_atwritten bylogRitual. It is the only oneof the six timezone reads in the repo missing that filter.