Skip to content

time: loadZoneInfo should allow version 3 #8134

@gopherbot

Description

@gopherbot

by roarofthefour:

The time zone records for Israel, Gaza, and some other places are not available via the
"time" package anymore, if you are using recent versions of zoneinfo.zip (such
as the one supplied with Go 1.2).

You can get at these time zone records if your zoneinfo.zip is old enough.

That's not good because zoneinfo.zip needs to be kept up-to-date with the latest changes
to Daylight Savings Time rules by various governments of the world.

Records for IANA time zones in zoneinfo.zip contain a version number.
Most records are version 2.
Some of them are version 3 now, such as Asia/Jerusalem, Asia/Gaza.

The following lines in the function loadZoneData

// 1-byte version, then 15 bytes of padding
    var p []byte
    if p = d.read(16); len(p) != 16 || p[0] != 0 && p[0] != '2' {
        return nil, badData
    }

should be changed to

// 1-byte version, then 15 bytes of padding
    var p []byte
    if p = d.read(16); len(p) != 16 || p[0] != 0 && p[0] != '2' || p[0] != '3' {
        return nil, badData
    }

to accommodate version 3.

The difference between version 2 records and version 3 does not concern loadZoneInfo,
because it does not read the part of the record which may be different under version 3,
that is, the POSIX TZ string.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions