Skip to content

archive/zip: document that zip times are stored/loaded using UTC #7592

Description

@gopherbot

by 518lee:

What does 'go version' print?
go version go1.2.1 linux/amd64
go version go1.2.1 windows/386

What steps reproduce the problem?
1. My computer time local is UTC+8
2. I write some codes to create a zip file:
     // Create a new zip archive.
    zw := zip.NewWriter(fw)
    defer zw.Close()

    //create zip dir item
    ffh := &zip.FileHeader{
        Name:   zipInnerFolder,
        Method: zip.Deflate,
    }
    ffh.SetModTime(time.Now())
    ffh.SetMode(os.ModeDir)

    //open zip dir item writor
    zw.CreateHeader(ffh)
3. When I run above code, the ModTime of the zip item is wrong(always UTC time)

What happened?
The ModTime of the zip item is wrong(always UTC time)


What should have happened instead?
The ModTime of the zip item should be just the right time based on the computer timezone

Please provide any additional information below.

Line 171: http://golang.org/src/pkg/archive/zip/struct.go

just remove this line or modify it to :
t = t.In(time.Local)

Others info:
https://groups.google.com/forum/#!topic/golang-checkins/hfyN7EHBH3A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions