Skip to content

Use deterministic UTC parsing for birth dates#27

Merged
jordanhom merged 1 commit intomainfrom
codex/refactor-handlecalculation-to-use-utc-parsing
Feb 6, 2026
Merged

Use deterministic UTC parsing for birth dates#27
jordanhom merged 1 commit intomainfrom
codex/refactor-handlecalculation-to-use-utc-parsing

Conversation

@jordanhom
Copy link
Owner

Motivation

  • Prevent timezone-dependent validation and calculation errors by avoiding local-time Date parsing and getTimezoneOffset adjustments.

Description

  • In handleCalculation (in js/ui.js) replace the local-Date + getTimezoneOffset normalization with deterministic UTC parsing by splitting the input and calling new Date(Date.UTC(year, monthIndex, day)).
  • Validate the parsed date by comparing parsed year/month/day components to the created UTC Date to catch invalid inputs (e.g. 2021-02-30).
  • Compare the parsed birth date against a UTC "today" computed with Date.UTC to ensure the date is strictly in the past.

Testing

  • No automated tests were run as part of this change.

Codex Task

@jordanhom jordanhom merged commit f6ca64a into main Feb 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant