REXX DATE() Fixed Offset or External OS date for Regional Time Zone Conversion
0 reputation · 10 Mar 2023, 04:57 UTC
0 reputation · 10 Mar 2023, 04:57 UTC
A REXX script must present the same instant in a regional time zone chosen at runtime, not merely the interpreter host's local time.
Classic REXX, Object REXX, Open Object REXX, and Regina expose DATE() and TIME() bound to the operating system's configured zone and DST rules. DATE('S') supports fixed-offset arithmetic from the REXX base date, but carries no time-zone metadata and cannot model daylight-saving transitions or historical zone changes. Calling an external Unix date or Windows PowerShell command can perform conversion, but output parsing depends on OS version and locale.
Behavior must be confirmed against the specific interpreter and host OS because DATE() is host-dependent and not defined by the REXX language specification.
Which approach preserves correctness across daylight-saving boundaries while remaining maintainable across REXX implementations? Is there a documented REXX extension that accepts IANA or Windows time-zone identifiers without external process execution?
35275 reputation · 10 Mar 2023, 12:29 UTC
The only approach that reliably preserves correctness across daylight‑saving boundaries while staying maintainable across REXX implementations is to call the host operating system’s date/PowerShell command with the desired time‑zone identifier and parse its output. No documented REXX extension accepts IANA or Windows time‑zone identifiers without invoking an external process.
Because DATE() cannot be re‑zoned, the portable way to obtain a local‑time representation for an arbitrary zone is to delegate the conversion to the OS, which already knows the zone’s rules, and then read the formatted result back into REXX.
DATE('S') (or TIME('S') combined with DATE) – this value is zone‑agnostic.TZ environment variable (Unix) or use the -TimeZone parameter (PowerShell) to the desired IANA or Windows identifier.date -d @ '+%Y-%m-%d %H:%M:%S %Z'[datetime]::FromFileTimeUtc(([int64]$epoch * 10000000) + 116444736000000000).ToString('yyyy-MM-dd HH:mm:ss zzz') (or simpler: Get-Date -Epoch $epoch -TimeZone "")To give the exact command syntax, please confirm the host OS family (Unix/Linux, Windows, or other) you are targeting; this determines whether to use the Unix date utility or Windows PowerShell.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.