Skip to content

feat: add dst-fold-first feature for handling ambiguous DST times#145

Open
zhwei wants to merge 1 commit intofmeringdal:mainfrom
zhwei:main
Open

feat: add dst-fold-first feature for handling ambiguous DST times#145
zhwei wants to merge 1 commit intofmeringdal:mainfrom
zhwei:main

Conversation

@zhwei
Copy link

@zhwei zhwei commented Feb 7, 2026

Add a new feature flag 'dst-fold-first' that changes the behavior when encountering ambiguous local times during DST transitions.

Behavior:

  • Without feature: Returns error for ambiguous DST times
  • With feature enabled: Picks the first (earlier) occurrence

Implementation:

  • parser/datetime.rs: Handle Ambiguous LocalResult by selecting first datetime
  • iter/utils.rs: Handle Ambiguous LocalResult in add_time_to_date function

Tests (America/Mexico_City 2021-2022 DST transitions):

  • dst_ambiguous_time_returns_error: Verifies error without feature
  • dst_fold_first_picks_earlier_time: Verifies first (-05:00) is selected
  • dst_fold_first_mexico_city_yearly: Tests yearly recurrence across DST

Note: Only affects 'Ambiguous' LocalResult (fall back overlap), not 'None' (spring forward gap). Mexico eliminated DST after 2022.

Usage:
cargo build --features dst-fold-first

Add a new feature flag 'dst-fold-first' that changes the behavior
when encountering ambiguous local times during DST transitions.

Behavior:
- Without feature: Returns error for ambiguous DST times
- With feature enabled: Picks the first (earlier) occurrence

Implementation:
- parser/datetime.rs: Handle Ambiguous LocalResult by selecting first datetime
- iter/utils.rs: Handle Ambiguous LocalResult in add_time_to_date function

Tests (America/Mexico_City 2021-2022 DST transitions):
- dst_ambiguous_time_returns_error: Verifies error without feature
- dst_fold_first_picks_earlier_time: Verifies first (-05:00) is selected
- dst_fold_first_mexico_city_yearly: Tests yearly recurrence across DST

Note: Only affects 'Ambiguous' LocalResult (fall back overlap), not 'None'
(spring forward gap). Mexico eliminated DST after 2022.

Usage:
  cargo build --features dst-fold-first
@zhwei
Copy link
Author

zhwei commented Feb 7, 2026

It looks like the lints test was already broken before this PR.

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.

1 participant