]> Cypherpunks repositories - gostls13.git/commit
archive/zip: add FileHeader.Modified field
authorJoe Tsai <joetsai@digital-static.net>
Mon, 28 Aug 2017 19:07:58 +0000 (12:07 -0700)
committerJoe Tsai <thebrokentoaster@gmail.com>
Mon, 6 Nov 2017 19:50:28 +0000 (19:50 +0000)
commit6e8894d5ffca9acc635e0d7298167122ed52ce55
tree4a61bd4b90a66375e7855df7ea2912dacad6f311
parent37b056948d058679efa4e87fb6c9b2a2ddfa31a3
archive/zip: add FileHeader.Modified field

The ModifiedTime and ModifiedDate fields are not expressive enough
for many of the time extensions that have since been added to ZIP,
nor are they easy to access since they in a legacy MS-DOS format,
and must be set and retrieved via the SetModTime and ModTime methods.

Instead, we add new field Modified of time.Time type that contains
all of the previous information and more.

Support for extended timestamps have been attempted before, but the
change was reverted because it provided no ability for the user to
specify the timezone of the legacy MS-DOS fields.
Technically the old API did not either, but users were manually offsetting
the timestamp to achieve the same effect.

The Writer now writes the legacy timestamps according to the timezone
of the FileHeader.Modified field. When the Modified field is set via
the SetModTime method, it is in UTC, which preserves the old behavior.

The Reader attempts to determine the timezone if both the legacy
and extended timestamps are present since it can compute the delta
between the two values.

Since Modified is a superset of the information in ModifiedTime and ModifiedDate,
we mark ModifiedTime, ModifiedDate, ModTime, and SetModTime as deprecated.

Fixes #18359

Change-Id: I29c6bc0a62908095d02740df3e6902f50d3152f1
Reviewed-on: https://go-review.googlesource.com/74970
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
13 files changed:
src/archive/zip/reader.go
src/archive/zip/reader_test.go
src/archive/zip/struct.go
src/archive/zip/testdata/time-7zip.zip [new file with mode: 0644]
src/archive/zip/testdata/time-go.zip [new file with mode: 0644]
src/archive/zip/testdata/time-infozip.zip [new file with mode: 0644]
src/archive/zip/testdata/time-osx.zip [new file with mode: 0644]
src/archive/zip/testdata/time-win7.zip [new file with mode: 0644]
src/archive/zip/testdata/time-winrar.zip [new file with mode: 0644]
src/archive/zip/testdata/time-winzip.zip [new file with mode: 0644]
src/archive/zip/writer.go
src/archive/zip/writer_test.go
src/archive/zip/zip_test.go