Skip to content

TZ environment variable doesn't parse POSIX strings correctly #46246

@mattjohnsonpint

Description

@mattjohnsonpint

Version

v16.14.0

Platform

Darwin XHFHLG2CJP.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64

Subsystem

No response

What steps will reproduce the bug?

When the TZ environment variable is set and interpreted by Node, it should support any of the formats allowed by the TZ environment variable (see man tzset).

It does appear to support IANA time zones (ex America/Los_Angeles) and POSIX time zones (ex PST8PDT), but it is not supporting POSIX time zones that include minutes or seconds in the offset, which is allowed by the TZ spec.

Example that works:

TZ=XXX+12 node -e 'console.log((new Date).getTimezoneOffset())'
# returns 720

Example that should work and does not:

TZ=XXX+12:00 node -e 'console.log((new Date).getTimezoneOffset())'
# should return 720, but returns whatever the local system's current time zone offset is

How often does it reproduce? Is there a required condition?

always reproducible

What is the expected behavior?

The TZ format should work in its entirety, as in the spec https://man7.org/linux/man-pages/man3/tzset.3.html

What do you see instead?

Only IANA time zones, or POSIX time zones with simple whole-hour offsets are supported.

Additional information

https://stackoverflow.com/questions/75150048/tz-utc0300-vs-tz-utc3-difference-for-nodejs

Metadata

Metadata

Assignees

No one assigned

    Labels

    icuIssues and PRs related to the ICU dependency.wrong repoIssues that should be opened in another repository.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions