Sha256: 9aabdc751e833960feedbf49723fcd1ba3a254234d65dd7d62099d929703d14b
Contents?: true
Size: 981 Bytes
Versions: 1
Compression:
Stored size: 981 Bytes
Contents
module RiCal class PropertyValue class UtcOffset < PropertyValue # :nodoc: attr_accessor :sign, :hours, :minutes, :seconds def value=(string) @value = string parse_match = /([+-])(\d\d)(\d\d)(\d\d)?/.match(string) if parse_match @sign = parse_match[1] == "+" ? 1 : -1 @hours = parse_match[2].to_i @minutes = parse_match[3].to_i @seconds = parse_match[4].to_i || 0 end end def to_seconds @sign * ((((hours*60) + minutes) * 60) + seconds) end def add_to_date_time_value(date_time_value) date_time_value.advance(:hours => sign * hours, :minutes => sign * minutes, :seconds => sign * minutes) end def subtract_from_date_time_value(date_time_value) signum = -1 * sign date_time_value.advance(:hours => signum * hours, :minutes => signum * minutes, :seconds => signum * minutes) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
friflaj_ri_cal-0.9.0 | lib/ri_cal/property_value/utc_offset.rb |