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