Skip to content

fix: timezone & offset issues - #9

Merged
hendurhance merged 2 commits into
mainfrom
fix/timezone-offset
Aug 23, 2026
Merged

fix: timezone & offset issues#9
hendurhance merged 2 commits into
mainfrom
fix/timezone-offset

Conversation

@hendurhance

Copy link
Copy Markdown
Owner

This pull request introduces several improvements and optimizations to the Chronos TypeScript date/time library, with a focus on more accurate timezone handling, improved parsing logic, and performance optimizations. The most significant changes are in how dates are parsed and compared in the presence of timezones, as well as the introduction of a formatter cache to reduce overhead in timezone calculations. Minor code cleanups and comment removals were also made for clarity.

Timezone and Parsing Improvements

  • Enhanced parsing of offset-less ISO 8601 strings in Chronos, ensuring they are resolved in the correct timezone and rejecting invalid dates more robustly. This prevents silent fallback to the process timezone and ensures accurate wall-clock interpretation.
  • All date comparison and arithmetic methods (isBefore, isAfter, isSame, isBetween, diff, etc.) now consistently use the instance's timezone for both operands, ensuring correct results when timezones are involved. This includes a new unitStart helper and logic for calendar unit differences. [1] [2] [3] [4] [5] [6]

Performance Optimizations

  • Introduced a cache for Intl.DateTimeFormat instances in timezone.ts, significantly reducing the performance cost of repeated zone-aware date formatting and offset calculations. [1] [2] [3]

Code Cleanup and Maintenance

  • Removed redundant comments and streamlined code in ChronosPeriod and ChronosPeriodCollection for better readability and maintainability. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]

Package and Export Adjustments

  • Bumped the package version to 2.0.5 and removed the postpublish script from package.json. [1] [2]
  • Minor export cleanups in index.ts and locales/index.ts. [1] [2]

…ess ISO strings

Fixes #7 & Unit-based comparisons use the process timezone instead of the instance timezone
Fixes #8
@hendurhance hendurhance added bug Something isn't working enhancement New feature or request labels Aug 23, 2026
@hendurhance hendurhance self-assigned this Aug 23, 2026
@hendurhance
hendurhance merged commit 049461c into main Aug 23, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant