Sha256: a90bf27de5db71a9016826374b5d2ff245245b49eb3b0ac519075319cdb929b8
Contents?: true
Size: 1.06 KB
Versions: 60
Compression:
Stored size: 1.06 KB
Contents
module RiCal class PropertyValue #- ©2009 Rick DeNatale, All rights reserved. Refer to the file README.txt for the license # 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
60 entries across 60 versions & 8 rubygems