Class: Zip::DOSTime

Inherits:
Time
  • Object
show all
Defined in:
lib/zip/dos_time.rb

Overview

:nodoc:all

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.parse_binary_dos_format(binaryDosDate, binaryDosTime) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/zip/dos_time.rb', line 33

def self.parse_binary_dos_format(binaryDosDate, binaryDosTime)
  second = 2 * (       0b11111 & binaryDosTime)
  minute = (     0b11111100000 & binaryDosTime) >> 5 
  hour   = (0b1111100000000000 & binaryDosTime) >> 11
  day    = (           0b11111 & binaryDosDate) 
  month  = (       0b111100000 & binaryDosDate) >> 5
  year   = ((0b1111111000000000 & binaryDosDate) >> 9) + 1980
  begin
    return self.local(year, month, day, hour, minute, second)
  end
end

Instance Method Details

#dos_equals(other) ⇒ Object

Dos time is only stored with two seconds accuracy



29
30
31
# File 'lib/zip/dos_time.rb', line 29

def dos_equals(other)
  to_i/2 == other.to_i/2
end

#to_binary_dos_dateObject



22
23
24
25
26
# File 'lib/zip/dos_time.rb', line 22

def to_binary_dos_date
  (day) +
  (month << 5) +
  ((year - 1980) << 9)
end

#to_binary_dos_timeObject

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)



16
17
18
19
20
# File 'lib/zip/dos_time.rb', line 16

def to_binary_dos_time
  (sec/2) +
  (min  << 5) +
  (hour << 11)
end