Class: Vobject::Vcalendar::PropertyValue::DateTimeUTC

Inherits:
PropertyValue
  • Object
show all
Includes:
Comparable
Defined in:
lib/vobject/vcalendar/propertyvalue.rb

Instance Attribute Summary

Attributes inherited from PropertyValue

#errors, #norm, #type, #value

Instance Method Summary collapse

Methods inherited from PropertyValue

#name, #to_norm

Constructor Details

#initialize(val) ⇒ DateTimeUTC

Returns a new instance of DateTimeUTC.



306
307
308
309
310
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 306

def initialize(val)
  self.value = val.clone
  value[:time] =  ::Time.utc(val[:year], val[:month], val[:day], val[:hour], val[:min], val[:sec])
  value[:origtime] = value[:time]
end

Instance Method Details

#<=>(another) ⇒ Object



302
303
304
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 302

def <=>(another)
  value[:time] <=> another.value[:time]
end

#to_hashObject



319
320
321
322
323
324
325
326
327
328
329
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 319

def to_hash
  ret = {
    year: value[:year],
    month: value[:month],
    day: value[:day],
    hour: value[:hour],
    min: value[:min],
    sec: value[:sec],
  }
  ret
end

#to_sObject



312
313
314
315
316
317
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 312

def to_s
  localtime = value[:origtime]
  ret = sprintf("%04d%02d%02dT%02d%02d%02dZ", localtime.year, localtime.month, localtime.day,
                localtime.hour, localtime.min, localtime.sec)
  ret
end