module RiCal::PropertyValue::DateTime::TimezoneSupport
-
©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license
Time zone related methods for DateTime
Public Instance Methods
floating?()
click to toggle source
Predicate indicating whether or not the instance represents a floating time
# File lib/ri_cal/property_value/date_time/timezone_support.rb, line 73 def floating? tzid.nil? end
has_local_timezone?()
click to toggle source
Determine if the receiver has a local time zone, i.e. it is not a floating time or a UTC time
# File lib/ri_cal/property_value/date_time/timezone_support.rb, line 36 def has_local_timezone? tzid && tzid.upcase != "UTC" end
in_time_zone(new_zone)
click to toggle source
Returns the simultaneous time in the specified zone.
# File lib/ri_cal/property_value/date_time/timezone_support.rb, line 86 def in_time_zone(new_zone) new_zone = timezone_finder.find_timezone(new_zone) return self if tzid == new_zone.identifier if has_local_timezone? new_zone.utc_to_local(utc) elsif utc? new_zone.utc_to_local(self) else # Floating time DateTime.new(timezone_finder, :value => @date_time_value, :tzid => new_zone.identifier) end end
tzid()
click to toggle source
Return the timezone id of the receiver, or nil if it is a floating time
# File lib/ri_cal/property_value/date_time/timezone_support.rb, line 9 def tzid @tzid == :floating ? nil : @tzid end
utc()
click to toggle source
Returns a instance that represents the time in UTC.
# File lib/ri_cal/property_value/date_time/timezone_support.rb, line 51 def utc if has_local_timezone? @utc ||= timezone.local_to_utc(self) else # Already local or a floating time self end end
utc?()
click to toggle source
Predicate indicating whether or not the instance represents a ZULU time
# File lib/ri_cal/property_value/date_time/timezone_support.rb, line 68 def utc? tzid == "UTC" end
with_floating_timezone()
click to toggle source
Return the receiver if it has a floating time zone already, otherwise return a DATETIME property with the same time as the receiver but with a floating time zone
# File lib/ri_cal/property_value/date_time/timezone_support.rb, line 42 def with_floating_timezone if @tzid == nil self else @date_time_value.with_floating_timezone.to_ri_cal_date_time_value end end