Should the APL DATETIME type include explicit time‑zone metadata?
0 reputation · 01 May 2021, 04:51 UTC
0 reputation · 01 May 2021, 04:51 UTC
The goal is to decide whether the built‑in DATETIME scalar in Dyalog APL should carry time‑zone information so that conversions between regions can be performed without relying on external extensions.
Currently DATETIME stores a local‑time value without any offset, which forces projects to adopt ad‑hoc solutions such as storing UTC offsets separately or using third‑party libraries, leading to inconsistent handling of daylight‑saving changes.
What are the implications for existing code if DATETIME gains a timezone field? How would timezone‑aware DATETIME interact with the existing DATE, TIME, and TIMESTAMP primitives? Should the timezone be stored as a numeric offset from UTC or as an IANA zone identifier?
35775 reputation · 01 May 2021, 14:25 UTC
The built‑in DATETIME scalar in Dyalog APL should not be changed to embed time‑zone data by default. Instead, an opt‑in aware type or an optional zone attribute preserves existing semantics while providing reliable cross‑regional conversions.
Existing DATETIME values represent a local‑time snapshot without any offset. When projects need to convert between regions, they typically store a separate UTC offset or use third‑party libraries. Those approaches differ in how they treat daylight‑saving transitions, leading to inconsistent behavior.
Adding a mandatory zone field would silently alter the meaning of every existing local‑time value. Code that assumes the old semantics would now produce different results, breaking downstream logic that relies on the original interpretation.
DATE and TIME remain zoneless; they continue to represent calendar dates and clock times only.TIMESTAMP is the anchor for absolute instants. A time‑zone‑aware DATETIME can be resolved to a TIMESTAMP by applying the stored zone rules.Storing a numeric offset is inadequate because it cannot encode daylight‑saving rules or historical changes. An IANA zone identifier (e.g., Europe/London) is the preferred primary representation. The offset can be derived on demand for display or interop, but the zone must be stored to preserve future‑proof semantics.
DATETIME values keep their current meaning; no runtime changes are required.DATETIME must be updated to either reject mixed aware/unaware values or explicitly require a zone parameter.localize, convert-to-zone, to-UTC-instant) should be added as library functions rather than altering the core type.DATETIME scalar unchanged.DATETIME‑ATZ (or similar) type that stores local fields plus an IANA zone identifier.DATETIME‑ATZ to TIMESTAMP and back.To tailor the recommendation for your environment, please provide:
These details affect how the new DATETIME‑ATZ type will be implemented and how existing code will interoperate.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.