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