Class: Vobject::Vcalendar::PropertyValue::DateTimeLocal
- Inherits:
-
PropertyValue
- Object
- PropertyValue
- Vobject::Vcalendar::PropertyValue::DateTimeLocal
show all
- Includes:
- Comparable
- Defined in:
- lib/vobject/vcalendar/propertyvalue.rb
Instance Attribute Summary
#errors, #norm, #type, #value
Instance Method Summary
collapse
#name, #to_norm
Constructor Details
Returns a new instance of DateTimeLocal.
265
266
267
268
269
270
271
272
273
274
275
|
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 265
def initialize(val)
self.value = val.clone
self.type = "datetimeLocal"
value[:time] = if val[:zone].nil? || val[:zone].empty?
::Time.local(val[:year], val[:month], val[:day], val[:hour], val[:min], val[:sec])
else
::Time.utc(val[:year], val[:month], val[:day], val[:hour], val[:min], val[:sec])
end
value[:origtime] = value[:time]
end
|
Instance Method Details
#<=>(another) ⇒ Object
261
262
263
|
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 261
def <=>(another)
value[:time] <=> another.value[:time]
end
|
#to_hash ⇒ Object
286
287
288
289
290
291
292
293
294
295
296
297
|
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 286
def to_hash
ret = {
year: value[:year],
month: value[:month],
day: value[:day],
hour: value[:hour],
min: value[:min],
sec: value[:sec],
}
ret[:zone] = value[:zone] if value[:zone]
ret
end
|
#to_s ⇒ Object
277
278
279
280
281
282
283
|
# File 'lib/vobject/vcalendar/propertyvalue.rb', line 277
def to_s
ret = sprintf("%s%s%sT%s%s%s", value[:year], value[:month], value[:day], value[:hour], value[:min], value[:sec])
zone = "Z" if value[:zone] && value[:zone] == "Z"
ret = ret + zone if !zone.nil?
ret
end
|