Skip to content

fix(today): base "time till next class" on Singapore time - #4442

Open
TheMythologist wants to merge 5 commits into
masterfrom
fix/today-next-class-countdown-timezone
Open

fix(today): base "time till next class" on Singapore time#4442
TheMythologist wants to merge 5 commits into
masterfrom
fix/today-next-class-countdown-timezone

Conversation

@TheMythologist

@TheMythologist TheMythologist commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The Today view computed the next-lesson countdown by placing the lesson start time on the viewer's local calendar day while comparing against the true current instant. Since lesson times are in Singapore time, overseas students saw a countdown that was off by their timezone offset.

Derive "now" from the SGT wall-clock (via toSingaporeTime) when reasoning about today, and anchor the lesson start time to that same reference so the displayed duration reflects the real time until the next class. No-op for viewers already on Singapore time.

Part of #3338

The Today view computed the next-lesson countdown by placing the lesson
start time on the viewer's local calendar day while comparing against the
true current instant. Since lesson times are in Singapore time, overseas
students saw a countdown that was off by their timezone offset.

Derive "now" from the SGT wall-clock (via toSingaporeTime) when reasoning
about today, and anchor the lesson start time to that same reference so the
displayed duration reflects the real time until the next class. No-op for
viewers already on Singapore time.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Actions Updated (UTC)
nusmods-export Ignored Ignored Preview Jul 5, 2026 10:38pm
nusmods-website Ignored Ignored Preview Jul 5, 2026 10:38pm

Request Review

@greptile-apps

greptile-apps Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes an incorrect "time till next class" countdown for overseas NUS students by converting the viewer's local currentTime to a Singapore-time wall-clock representation via toSingaporeTime before any date arithmetic. The same conversion is applied to semester/week selection in mapStateToProps and to the getStartTimeAsDate anchor in BeforeLessonCard, making the entire Today view timezone-consistent.

  • groupLessons and renderDay now derive currentTime from toSingaporeTime(this.props.currentTime), so day boundaries, lesson filtering, and the countdown all use SGT regardless of the viewer's local clock.
  • mapStateToProps also converts to SGT before computing lastDay and getAcadWeekInfo, preventing semester mismatches for overseas viewers.
  • One gap remains: isSameDay(date, holiday) at line 246 still compares the new fake-SGT date against a new Date("YYYY-MM-DD") holiday that is parsed as UTC midnight, which shows as the previous calendar day for western-timezone viewers — breaking holiday detection that worked coincidentally before this change.

Confidence Score: 4/5

The core countdown fix is sound, but a one-line holiday comparison still uses a raw UTC-midnight Date against the new SGT-based date, silently breaking holiday detection for viewers in western timezones.

The toSingaporeTime conversion is applied consistently across groupLessons, renderDay, and mapStateToProps, and BeforeLessonCard correctly anchors the lesson time to the same reference. The remaining gap is isSameDay(date, holiday) at line 246: holidays are stored as new Date("YYYY-MM-DD") (UTC midnight), which in western timezones resolves to the day before the intended SGT date — now that date is a fake-SGT Date the coincidental match that existed before is gone, so public holidays won't be detected for overseas users west of UTC.

website/src/views/today/TodayContainer/TodayContainer.tsx — specifically the isSameDay holiday check at line 246.

Reviews (5): Last reviewed commit: "fix(today): select semester in Singapore..." | Re-trigger Greptile

Comment thread website/src/views/today/TodayContainer/TodayContainer.tsx
@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.53%. Comparing base (988c6fd) to head (361be69).
⚠️ Report is 259 commits behind head on master.

Files with missing lines Patch % Lines
website/src/views/today/BeforeLessonCard.tsx 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4442      +/-   ##
==========================================
+ Coverage   54.52%   58.53%   +4.01%     
==========================================
  Files         274      316      +42     
  Lines        6076     7296    +1220     
  Branches     1455     1794     +339     
==========================================
+ Hits         3313     4271     +958     
- Misses       2763     3025     +262     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

TheMythologist and others added 3 commits July 1, 2026 11:08
Determine "today" and each subsequent day column from the SGT wall-clock
so the day grouping, the day marked as today, and the "time till next
class" countdown all agree. Previously grouping used the viewer's local
date while the countdown used SGT, so a viewer whose local date trailed
Singapore's saw the wrong day as today and a wrong countdown.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@jloh02

jloh02 commented Jul 5, 2026

Copy link
Copy Markdown
Member

We should probably fix greptile's comments in this samePR while we're at it?

mapStateToProps chose the semester/week timetable from the viewer's local
date, while the Today view groups days in Singapore time. An overseas
viewer whose local date trailed Singapore's could be served the previous
semester's timetable even as the day list showed the new semester's
lessons. Derive the week info from the SGT wall-clock so both agree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@TheMythologist

Copy link
Copy Markdown
Contributor Author

We should probably fix greptile's comments in this samePR while we're at it?

You're right - fixed in 361be69

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants