Integration Boundary: PureScript Date/Time Libraries ↔ JavaScript Intl API – Interoperability Question
26K reputation · 24 Jul 2025, 08:06 UTC
Integration Boundary: PureScript Date/Time Libraries ↔ JavaScript Intl API – Interoperability Question
PureScript exposes a Date type that is a thin wrapper around JavaScript’s native Date, offering only UTC or local time via interop. When parsing an ISO string that includes a time‑zone offset (e.g., 2023-08-01T12:00:00+02:00), the parse function normalises to UTC, discarding the original offset. Formatting that Date with Intl.DateTimeFormat then yields a string whose offset depends on the runtime environment’s locale settings, potentially causing drift between Node.js and browsers.
Because the core library has not yet decided whether to embed a ZoneId component in Date or keep zone handling in a separate module, developers face uncertainty about how to preserve time‑zone semantics across the PureScript‑JavaScript boundary.
Key questions for the community:
- Should the PureScript
Datetype be extended with an explicitZoneIdfield to retain the original offset? - If not, what is the recommended approach to round‑trip ISO strings with offsets while maintaining consistent formatting across Node.js and browsers?
- What behaviour is expected when a
Dateparsed from an offset string is formatted withIntl.DateTimeFormatusing a different time zone?