Please sign in to comment.
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 <email@example.com> Reviewed-by: Ian Lance Taylor <firstname.lastname@example.org>
- Loading branch information...
Showing with 403 additions and 120 deletions.
- +108 −37 src/archive/zip/reader.go
- +165 −60 src/archive/zip/reader_test.go
- +63 −15 src/archive/zip/struct.go
- BIN src/archive/zip/testdata/time-7zip.zip
- BIN src/archive/zip/testdata/time-go.zip
- BIN src/archive/zip/testdata/time-infozip.zip
- BIN src/archive/zip/testdata/time-osx.zip
- BIN src/archive/zip/testdata/time-win7.zip
- BIN src/archive/zip/testdata/time-winrar.zip
- BIN src/archive/zip/testdata/time-winzip.zip
- +39 −6 src/archive/zip/writer.go
- +26 −0 src/archive/zip/writer_test.go
- +2 −2 src/archive/zip/zip_test.go
Oops, something went wrong.