Get rid of Time extensions
This commit is contained in:
		
							parent
							
								
									219b853412
								
							
						
					
					
						commit
						85054091e8
					
				|  | @ -1,18 +1,17 @@ | ||||||
| class Time  #:nodoc:all | class DOSTime < Time #:nodoc:all | ||||||
| 
 | 
 | ||||||
|   #MS-DOS File Date and Time format as used in Interrupt 21H Function 57H: |   #MS-DOS File Date and Time format as used in Interrupt 21H Function 57H: | ||||||
|   #  | 
 | ||||||
|   # Register CX, the Time: |   # Register CX, the Time: | ||||||
|   # Bits 0-4  2 second increments (0-29) |   # Bits 0-4  2 second increments (0-29) | ||||||
|   # Bits 5-10 minutes (0-59) |   # Bits 5-10 minutes (0-59) | ||||||
|   # bits 11-15 hours (0-24) |   # bits 11-15 hours (0-24) | ||||||
|   #  | 
 | ||||||
|   # Register DX, the Date: |   # Register DX, the Date: | ||||||
|   # Bits 0-4 day (1-31) |   # Bits 0-4 day (1-31) | ||||||
|   # bits 5-8 month (1-12) |   # bits 5-8 month (1-12) | ||||||
|   # bits 9-15 year (four digit year minus 1980) |   # bits 9-15 year (four digit year minus 1980) | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|   def to_binary_dos_time |   def to_binary_dos_time | ||||||
|     (sec/2) + |     (sec/2) + | ||||||
|     (min  << 5) + |     (min  << 5) + | ||||||
|  | @ -38,7 +37,7 @@ class Time  #:nodoc:all | ||||||
|     month  = (       0b111100000 & binaryDosDate) >> 5 |     month  = (       0b111100000 & binaryDosDate) >> 5 | ||||||
|     year   = ((0b1111111000000000 & binaryDosDate) >> 9) + 1980 |     year   = ((0b1111111000000000 & binaryDosDate) >> 9) + 1980 | ||||||
|     begin |     begin | ||||||
|       return Time.local(year, month, day, hour, minute, second) |       return self.local(year, month, day, hour, minute, second) | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
| end | end | ||||||
|  | @ -5,7 +5,7 @@ require 'tempfile' | ||||||
| require 'fileutils' | require 'fileutils' | ||||||
| require 'stringio' | require 'stringio' | ||||||
| require 'zlib' | require 'zlib' | ||||||
| require 'zip/stdrubyext' | require 'zip/dos_time' | ||||||
| require 'zip/ioextras' | require 'zip/ioextras' | ||||||
| require 'rbconfig' | require 'rbconfig' | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -82,7 +82,7 @@ module Zip | ||||||
|     def initialize(zipfile = "", name = "", comment = "", extra = "",  |     def initialize(zipfile = "", name = "", comment = "", extra = "",  | ||||||
|                    compressed_size = 0, crc = 0,  |                    compressed_size = 0, crc = 0,  | ||||||
|        compression_method = ZipEntry::DEFLATED, size = 0, |        compression_method = ZipEntry::DEFLATED, size = 0, | ||||||
|        time  = Time.now) |        time  = DOSTime.now) | ||||||
|       super() |       super() | ||||||
|       if name.start_with?("/") |       if name.start_with?("/") | ||||||
|         raise ZipEntryNameError, "Illegal ZipEntry name '#{name}', name must not start with /" |         raise ZipEntryNameError, "Illegal ZipEntry name '#{name}', name must not start with /" | ||||||
|  | @ -563,7 +563,7 @@ module Zip | ||||||
|     private |     private | ||||||
| 
 | 
 | ||||||
|     def set_time(binaryDosDate, binaryDosTime) |     def set_time(binaryDosDate, binaryDosTime) | ||||||
|       @time = Time.parse_binary_dos_format(binaryDosDate, binaryDosTime) |       @time = DOSTime.parse_binary_dos_format(binaryDosDate, binaryDosTime) | ||||||
|     rescue ArgumentError |     rescue ArgumentError | ||||||
|       puts "Invalid date/time in zip entry" |       puts "Invalid date/time in zip entry" | ||||||
|     end |     end | ||||||
|  |  | ||||||
|  | @ -64,9 +64,9 @@ module Zip | ||||||
|         size, content = initial_parse(binstr) |         size, content = initial_parse(binstr) | ||||||
|         size or return |         size or return | ||||||
|         @flag, mtime, atime, ctime = content.unpack("CVVV") |         @flag, mtime, atime, ctime = content.unpack("CVVV") | ||||||
|         mtime and @mtime ||= Time.at(mtime) |         mtime and @mtime ||= DOSTime.at(mtime) | ||||||
|         atime and @atime ||= Time.at(atime) |         atime and @atime ||= DOSTime.at(atime) | ||||||
|         ctime and @ctime ||= Time.at(ctime) |         ctime and @ctime ||= DOSTime.at(ctime) | ||||||
|       end |       end | ||||||
| 
 | 
 | ||||||
|       def ==(other) |       def ==(other) | ||||||
|  |  | ||||||
|  | @ -187,7 +187,7 @@ class ZipFsFileNonmutatingTest < Test::Unit::TestCase | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def test_utime |   def test_utime | ||||||
|     t_now = Time.now |     t_now = DOSTime.now | ||||||
|     t_bak = @zipFile.file.mtime("file1") |     t_bak = @zipFile.file.mtime("file1") | ||||||
|     @zipFile.file.utime(t_now, "file1") |     @zipFile.file.utime(t_now, "file1") | ||||||
|     assert_equal(t_now, @zipFile.file.mtime("file1")) |     assert_equal(t_now, @zipFile.file.mtime("file1")) | ||||||
|  | @ -315,17 +315,17 @@ class ZipFsFileNonmutatingTest < Test::Unit::TestCase | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|   def test_mtime |   def test_mtime | ||||||
|     assert_equal(Time.at(1027694306), |     assert_equal(DOSTime.at(1027694306), | ||||||
|       @zipFile.file.mtime("dir2/file21")) |       @zipFile.file.mtime("dir2/file21")) | ||||||
|     assert_equal(Time.at(1027690863), |     assert_equal(DOSTime.at(1027690863), | ||||||
|       @zipFile.file.mtime("dir2/dir21")) |       @zipFile.file.mtime("dir2/dir21")) | ||||||
|     assert_raise(Errno::ENOENT) { |     assert_raise(Errno::ENOENT) { | ||||||
|       @zipFile.file.mtime("noSuchEntry") |       @zipFile.file.mtime("noSuchEntry") | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     assert_equal(Time.at(1027694306), |     assert_equal(DOSTime.at(1027694306), | ||||||
|       @zipFile.file.stat("dir2/file21").mtime) |       @zipFile.file.stat("dir2/file21").mtime) | ||||||
|     assert_equal(Time.at(1027690863), |     assert_equal(DOSTime.at(1027690863), | ||||||
|       @zipFile.file.stat("dir2/dir21").mtime) |       @zipFile.file.stat("dir2/dir21").mtime) | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -222,7 +222,7 @@ class ZipLocalEntryTest < Test::Unit::TestCase | ||||||
|       |file| |       |file| | ||||||
|       entry = ZipEntry.read_local_entry(file) |       entry = ZipEntry.read_local_entry(file) | ||||||
|       assert_equal("zippedruby1.rb", entry.name) |       assert_equal("zippedruby1.rb", entry.name) | ||||||
|       assert_equal(Time.at(1019261638), entry.time) |       assert_equal(DOSTime.at(1019261638), entry.time) | ||||||
|     } |     } | ||||||
|   end |   end | ||||||
| 
 | 
 | ||||||
|  | @ -1679,7 +1679,7 @@ class ZipExtraFieldTest < Test::Unit::TestCase | ||||||
|     extra3 = ZipExtraField.new(str) |     extra3 = ZipExtraField.new(str) | ||||||
|     assert_equal(extra1, extra2) |     assert_equal(extra1, extra2) | ||||||
|     |     | ||||||
|     extra2["UniversalTime"].mtime = Time.now |     extra2["UniversalTime"].mtime = DOSTime.now | ||||||
|     assert(extra1 != extra2) |     assert(extra1 != extra2) | ||||||
| 
 | 
 | ||||||
|     extra3.create("IUnix") |     extra3.create("IUnix") | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue