mirror of
https://github.com/golang/go
synced 2024-11-24 01:20:08 -07:00
archive/zip: use UTC for all FileInfo timestamps for consistency
This commit is contained in:
parent
8cb8b4113d
commit
13e94be3f8
@ -159,7 +159,7 @@ func (fi headerFileInfo) ModTime() time.Time {
|
||||
if fi.fh.Modified.IsZero() {
|
||||
return fi.fh.ModTime()
|
||||
}
|
||||
return fi.fh.Modified
|
||||
return fi.fh.Modified.UTC()
|
||||
}
|
||||
func (fi headerFileInfo) Mode() os.FileMode { return fi.fh.Mode() }
|
||||
func (fi headerFileInfo) Sys() interface{} { return fi.fh }
|
||||
@ -178,7 +178,6 @@ func FileInfoHeader(fi os.FileInfo) (*FileHeader, error) {
|
||||
UncompressedSize64: uint64(size),
|
||||
}
|
||||
fh.SetModTime(fi.ModTime())
|
||||
fh.Modified = fi.ModTime()
|
||||
fh.SetMode(fi.Mode())
|
||||
if fh.UncompressedSize64 > uint32max {
|
||||
fh.UncompressedSize = uint32max
|
||||
|
@ -127,10 +127,10 @@ func TestFileHeaderRoundTripModified(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got, want := fh2.Modified, fh.Modified; got != want {
|
||||
if got, want := fh2.Modified, fh.Modified.UTC(); got != want {
|
||||
t.Errorf("Modified: got %s, want %s\n", got, want)
|
||||
}
|
||||
if got, want := fi.ModTime(), fh.Modified; got != want {
|
||||
if got, want := fi.ModTime(), fh.Modified.UTC(); got != want {
|
||||
t.Errorf("Modified: got %s, want %s\n", got, want)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user