-
Notifications
You must be signed in to change notification settings - Fork 18k
archive/zip: record time stamps in "Extended Timestamp Extra Field" #10242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Most of zip archiver store timestamp as local timezone. |
I don't think we can safely make this change under the Go 1 compatibility guarantee. |
I'm thinking this is a bug. So we must not keep compatibility.
make
package main
import (
"archive/zip"
"fmt"
"log"
"os"
)
func main() {
in, err := os.Open("test.zip")
if err != nil {
log.Fatal("opening:", err)
}
defer in.Close()
info, err := in.Stat()
if err != nil {
log.Fatal("stat:", err)
}
zr, err := zip.NewReader(in, info.Size())
if err != nil {
log.Fatal("NewReader:", err)
}
if len(zr.File) != 1 {
log.Fatalf("File count should be 1 but %v", len(zr.File))
}
ztime := zr.File[0].ModTime()
fmt.Println(ztime.String())
}
Note that this is not a joke at april fool. |
I'm in JST+0900 offset |
As I understand it, the only possibly correct fix is to use the "Extended Timestamp Extra Field" defined at http://www.opensource.apple.com/source/zip/zip-6/unzip/unzip/proginfo/extra.fld . |
This came up in #7592, which we fixed by updating the documentation for the ModTime and SetModTime methods. It is not possible to change the UTC default. It may be that if we set this extended field as well, enough clients will use the Unix form in preference to the MS-DOS form that they will end up doing the right thing. |
I looked code of unzip. unzip command can extract timestamp as local timezon without looking extra field. Proposal
How do you think? |
Which version of unzip did you look at? I don't know if extending the API is the way to go, but, if it is, why would we need both DefaultTimeZone and SetTimeZone? |
I looked master branch of https://github.com/Distrotech/unzip |
Too late for Go 1.5. |
CL https://golang.org/cl/18274 mentions this issue. |
CL https://golang.org/cl/34651 mentions this issue. |
This change reverts the following CLs: CL/18274: handle mtime in NTFS/UNIX/ExtendedTS extra fields CL/30811: only use Extended Timestamp on non-zero MS-DOS timestamps We are reverting support for extended timestamps since the support was not not complete. CL/18274 added full support for reading extended timestamp fields and minimal support for writing them. CL/18274 is incomplete because it made no changes to the FileHeader struct, so timezone information was lost when reading and/or writing. While CL/18274 was a step in the right direction, we should provide full support for high precision timestamps in both the reader and writer. This will probably require that we add a new field of type time.Time. The complete fix is too involved to add in the time remaining for Go 1.8 and will be completed in Go 1.9. Updates #10242 Updates #17403 Updates #18359 Fixes #18378 Change-Id: Icf6d028047f69379f7979a29bfcb319a02f4783e Reviewed-on: https://go-review.googlesource.com/34651 Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Change https://golang.org/cl/44394 mentions this issue: |
Change https://golang.org/cl/36078 mentions this issue: |
timestamp of the file in the zip, is UTC timezone. So +9 hours in my location.
The text was updated successfully, but these errors were encountered: