Class: Time

Inherits:
Object
  • Object
show all
Defined in:
lib/archive/support/time.rb

Instance Method Summary collapse

Instance Method Details

#to_dos_timeObject

Returns a DOSTime representing this time object as a DOS date-time structure. Times are bracketed by the limits of the ability of the DOS date-time structure to represent them. Accuracy is 2 seconds and years range from 1980 to 2099. The returned structure represents as closely as possible the time of this object.

See DOSTime#new for a description of this structure.


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/archive/support/time.rb', line 11

def to_dos_time
  dos_sec  = sec/2
  dos_year = year - 1980
  dos_year = 0   if dos_year < 0
  dos_year = 119 if dos_year > 119

  DOSTime.new(
    (dos_sec       ) |
    (min      <<  5) |
    (hour     << 11) |
    (day      << 16) |
    (month    << 21) |
    (dos_year << 25)
  )
end