Add `Entry#absolute_time?`.
This method returns `true` if an entry has timezone information in its timestamps, `false` otherwise.
This commit is contained in:
parent
8afc2514f7
commit
d53f046bc7
|
@ -176,6 +176,11 @@ module Zip
|
||||||
send(:time=, value, component: :ctime)
|
send(:time=, value, component: :ctime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Does this entry return time fields with accurate timezone information?
|
||||||
|
def absolute_time?
|
||||||
|
@extra.member?('UniversalTime') || @extra.member?('NTFS')
|
||||||
|
end
|
||||||
|
|
||||||
# Return the compression method for this entry.
|
# Return the compression method for this entry.
|
||||||
#
|
#
|
||||||
# Returns STORED if the entry is a directory or if the compression
|
# Returns STORED if the entry is a directory or if the compression
|
||||||
|
|
|
@ -340,4 +340,12 @@ class ZipEntryTest < MiniTest::Test
|
||||||
entry.gather_fileinfo_from_srcpath('test/data/mimetype')
|
entry.gather_fileinfo_from_srcpath('test/data/mimetype')
|
||||||
assert_equal(entry.time, File.stat('test/data/mimetype').mtime)
|
assert_equal(entry.time, File.stat('test/data/mimetype').mtime)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_absolute_time
|
||||||
|
entry = ::Zip::Entry.new
|
||||||
|
refute(entry.absolute_time?)
|
||||||
|
|
||||||
|
entry.time = Time.now
|
||||||
|
assert(entry.absolute_time?)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue