Module: Iso9660::Util
- Defined in:
- lib/fs/iso9660/util.rb
Constant Summary collapse
- ISO_DATE =
BinaryStruct.new([ 'a4', 'year', # Absolute year. 'a2', 'month', 'a2', 'day', 'a2', 'hour', 'a2', 'min', 'a2', 'sec', 'a2', 'hun', 'c', 'offset' # 15-min intervals (iow 4 per time zone). ])
- ISO_DATE_SHORT =
BinaryStruct.new([ 'C', 'year', # Since 1900. 'C', 'month', 'C', 'day', 'C', 'hour', 'C', 'min', 'C', 'sec', 'c', 'offset' # 15-min intervals. ])
Class Method Summary collapse
- .GetShortTimezone(isoShort) ⇒ Object
- .GetTimezone(isodate) ⇒ Object
- .IsoShortToRubyDate(isoShort) ⇒ Object
- .IsoToRubyDate(isodate) ⇒ Object
Class Method Details
.GetShortTimezone(isoShort) ⇒ Object
53 54 55 |
# File 'lib/fs/iso9660/util.rb', line 53 def self.GetShortTimezone(isoShort) isoShort[7] / 4 end |
.GetTimezone(isodate) ⇒ Object
39 40 41 |
# File 'lib/fs/iso9660/util.rb', line 39 def self.GetTimezone(isodate) isodate[16, 1].unpack('c')[0] / 4 end |
.IsoShortToRubyDate(isoShort) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/fs/iso9660/util.rb', line 43 def self.IsoShortToRubyDate(isoShort) return Time.at(0).gmtime if isoShort == "\0" * 7 begin tv = OpenStruct.new(ISO_DATE_SHORT.decode(isoShort)) rescue return Time.at(0).gmtime end Time.gm(tv.sec, tv.min, tv.hour, tv.day, tv.month, tv.year + 1900, nil, nil, nil, tv.offset / 4) end |
.IsoToRubyDate(isodate) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/fs/iso9660/util.rb', line 30 def self.IsoToRubyDate(isodate) begin tv = OpenStruct.new(ISO_DATE.decode(isodate)) rescue return Time.at(0).gmtime end Time.gm(tv.sec, tv.min, tv.hour, tv.day, tv.month, tv.year, nil, nil, nil, tv.offset / 4) end |