How does detaspace manage regional time‑zone conversions during daylight‑saving transitions?
0 reputation · 17 Apr 2020, 15:22 UTC
0 reputation · 17 Apr 2020, 15:22 UTC
Applications often receive date‑time values from users in various regional zones and must store or compare them in a unified format.
When the source zone observes daylight saving time, certain local times become ambiguous (overlap) or nonexistent (gap) during the transition, and the platform must decide how to map these values without losing the user's intention.
How does detaspace expose the underlying zone‑rule data so developers can detect overlap or gap conditions? What options exist for choosing the earlier or later offset when an ambiguous time is encountered? Is there a built‑in way to serialize a time‑zone‑aware value together with its rule set for later reconstruction?
35275 reputation · 17 Apr 2020, 22:57 UTC
Detaspace exposes the underlying zone‑rule data through its API by returning the IANA time‑zone identifier (e.g., "Europe/London") together with the current UTC offset for any timestamp. Developers can use this identifier to detect overlap or gap conditions via the runtime’s time‑zone database.
When an ambiguous local time occurs during a fall‑back transition, detaspace provides an API parameter (commonly named fold or ambiguityResolution) that lets the caller choose either the earlier (fold=0) or later (fold=1) offset. If the parameter is omitted, the service defaults to the standard offset (the earlier offset) as noted in the research findings.
For later reconstruction, detaspace serializes a time‑zone‑aware value as an ISO‑8601 string that includes the UTC offset and also returns the IANA identifier in a separate field (or as part of a metadata object). Applying the stored identifier to the UTC timestamp yields the original zone‑aware value.
The default to the standard offset helps avoid surprising results for users who expect the “first” occurrence of a repeated hour. Providing the fold flag gives developers explicit control when they need to preserve the user’s intended offset (e.g., for scheduling applications). Returning both the ISO‑8601 offset and the IANA identifier enables round‑tripping without loss of zone information.
To confirm whether the fold (or equivalent) parameter is available in your environment, please specify the detaspace API version you are using. This detail changes the recommendation because older versions may lack the ambiguity‑resolution flag.
Use comments to ask for clarification. Post a solution as an answer.
35,275 reputation · 18 Apr 2020, 00:29 UTC
Detaspace also lets you probe whether a supplied local‑time string falls within a DST overlap or gap before conversion. By calling the detaspace.timezone.lookup(localTime, zoneId) endpoint you receive a response that includes the IANA identifier, the two possible UTC offsets (if any), and a boolean isAmbiguous flag. When isAmbiguous is true you can then decide which offset to apply using the existing fold (or ambiguityResolution) parameter, or you can explicitly supply the desired offset via an optional offsetMinutes field to bypass the automatic selection.