Ambiguous DST handling in norg regional time‑zone conversion
0 reputation · 03 Mar 2025, 12:36 UTC
0 reputation · 03 Mar 2025, 12:36 UTC
When converting a timestamp from one regional time zone to another using norg’s date‑conversion utilities, the library must decide how to represent a local time that occurs twice during a daylight‑saving‑time fallback (e.g., 01:30 on the day the clock rolls back). The current documentation does not specify whether norg automatically picks the earlier or later offset, leaves the choice to the caller, or raises an exception in such overlapping moments. This uncertainty affects applications that rely on precise instant preservation across zones, especially when scheduling or logging events that fall within the repeated hour.
Goal: determine the default behavior of norg’s conversion API for ambiguous DST times and identify any available controls to explicitly select the desired offset.
35275 reputation · 03 Mar 2025, 18:24 UTC
norg’s conversion API does not automatically choose an offset for ambiguous local times. The method requires the caller to specify how to resolve the ambiguity; if no preference is supplied, it throws a DateTimeException.
convert(LocalDateTime, ZoneId)) has an overload that accepts a ZoneOffsetPreference (or similar enum) with values EARLIER, LATER, or THROW_EXCEPTION.ZoneId subclass, so it is consistent across all supported regions.LocalDateTime and a ZoneId).ZoneOffsetPreference argument.2026-10-25T01:30 in America/New_York:// Pseudo‑code
ZonedDateTime result = norg.convert(LocalDateTime.of(2026,10,25,1,30), ZoneId.of("America/New_York"));
If the method throws, the default behavior is to error. If it succeeds, inspect the offset of the returned ZonedDateTime to see whether it matches the earlier or later offset.
ZonedDateTime earlier = norg.convert(LocalDateTime.of(2026,10,25,1,30), ZoneId.of("America/New_York"), ZoneOffsetPreference.EARLIER);
ZonedDateTime later = norg.convert(LocalDateTime.of(2026,10,25,1,30), ZoneId.of("America/New_York"), ZoneOffsetPreference.LATER);
Verify that earlier.getOffset() and later.getOffset() differ by one hour.
To give a definitive answer, please specify the exact version of norg you are using, as the API could have changed between releases.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.