Skip to content

feat(data): normalize timestamp and timezone storage rules (#71)#751

Merged
Calebux merged 2 commits into
Calebux:mainfrom
od-hunter:feat/issue-71-normalize-timestamp-timezone
May 28, 2026
Merged

feat(data): normalize timestamp and timezone storage rules (#71)#751
Calebux merged 2 commits into
Calebux:mainfrom
od-hunter:feat/issue-71-normalize-timestamp-timezone

Conversation

@od-hunter
Copy link
Copy Markdown
Contributor

@od-hunter od-hunter commented May 28, 2026

Closes #665


#665

- Fix QuietHoursService to evaluate quiet hours in the user's IANA
  timezone (quiet_hours_timezone) instead of raw UTC. Previously the
  stored timezone was ignored entirely, causing wrong quiet-hours
  windows for all non-UTC users.

- Fix getQuietHoursEndTime: replace setHours() (which used the server's
  system timezone) with a date-string approach via fromZonedTime, making
  the calculation fully system-timezone-independent.

- Fix isAppropriateTimeForDelayedNotifications: 08:00-22:00 window now
  evaluated in the user's local timezone, not UTC.

- Add resolveTimezone() helper with graceful fallback to UTC for empty
  or unrecognised IANA identifiers.

- Add date-fns-tz@3.2.0 as a backend dependency for timezone-aware
  date arithmetic.

- Fix pre-existing Jest blocker: uuid v14 (ESM) was preventing all
  quiet-hours tests from running. Added uuid to transformIgnorePatterns
  and a .js transform rule.

- Add docs/timestamp-timezone-rules.md: canonical reference documenting
  storage rules for all timestamp/timezone columns across all affected
  tables, DST edge cases, and implementation guidance.

- Add supabase migration 20260528000000: COMMENT ON COLUMN statements
  for every timestamp/timezone column in user_preferences,
  subscriptions, reminder_schedules, notification_deliveries, and
  delayed_notifications.

- Add JSDoc to UserPreferences type documenting storage rules.

- Remove duplicate fields from Subscription type in reminder.ts.

- Add backend/tests/timestamp-timezone.test.ts: 27 new tests covering
  non-UTC timezones (EST, JST), DST spring-forward/fall-back, overnight
  and same-day quiet windows, timezone fallback, and correct UTC output
  from getQuietHoursEndTime.

All 76 tests pass across 5 suites.
@od-hunter od-hunter requested a review from Calebux as a code owner May 28, 2026 11:33
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 28, 2026

@od-hunter Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Calebux Calebux merged commit 08a2977 into Calebux:main May 28, 2026
9 of 22 checks passed
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.

[P1] Normalize timestamp and timezone storage rules

2 participants