Skip to content

to_posix_string() returns invalid timezone string #94

@svekon-admin

Description

@svekon-admin

The following code
tz_database tz_db; tz_db.load_from_file("./date_time_zonespec.csv"); time_zone_ptr nyc = tz_db.time_zone_from_region("Europe/Stockholm"); auto s = nyc->to_posix_string(); setenv("TZ", s.c_str(), 1);
will set TZ to "CET+01CEST+01,M3.5.0/02:00,M10.5.0/03:00" which will cause Stockholm local time to be 10:00:00 when UTC(GMT/London) time is 11:00:00 which clearly is incorrect.

ANSI/IEEE Std 1003.1 section 8.3 Other Environment Variables reads for TZ variable

Offset Indicates the value added to the local time to arrive at Coordinated Universal Time

gnu.org reads the same
It also says regarding offset

This is positive if the local time zone is west of the Prime Meridian and negative if it is east.

But Boost 1.69 date-time says

A posix_time_zone is unique in that the object is created from a Posix time zone string (IEEE Std 1003.1). A POSIX time zone string takes the form of:
"std offset dst [offset],start[/time],end[/time]" (w/no spaces).
'std' specifies the abbrev of the time zone. 'offset' is the offset from UTC.
"PST-8PDT01:00:00,M4.1.0/02:00:00,M10.1.0/02:00:00"
"PST-8PDT,M4.1.0,M10.1.0"
These two are actually the same specification (defaults were used in the second string). This zone lies eight hours west of GMT …”

If I add -8 to a PST local time I will NOT get GMT=UTC time!! It seems like somewhere here (most likely in to_posix_string()) is a huge bug since the Posix/GNU and Boost interpretation of the Posix timezone strings contradict each other.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions