• Joe Tsai's avatar
    archive/zip: add FileHeader.Modified field · 6e8894d5
    Joe Tsai authored
    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: 's avatarIan Lance Taylor <iant@golang.org>
    6e8894d5