Generalize `Entry#time`.

So we can use it for `atime`, `ctime` and `utime` as well.
This commit is contained in:
Robert Haines 2022-02-23 12:39:01 +00:00
parent ae0262df2e
commit d6482bd567
1 changed files with 11 additions and 10 deletions

View File

@ -118,16 +118,17 @@ module Zip
gp_flags & 8 == 8
end
def time
if @extra['UniversalTime'] && !@extra['UniversalTime'].mtime.nil?
@extra['UniversalTime'].mtime
elsif @extra['NTFS'] && !@extra['NTFS'].mtime.nil?
@extra['NTFS'].mtime
else
def time(component: :mtime)
time =
if @extra['UniversalTime']
@extra['UniversalTime'].send(component)
elsif @extra['NTFS']
@extra['NTFS'].send(component)
end
# Standard time field in central directory has local time
# under archive creator. Then, we can't get timezone.
@time
end
time || (@time if component == :mtime)
end
alias mtime time