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

Version Path
demingfactor-ri_cal-0.10.0 lib/ri_cal/property_value/utc_offset.rb
demingfactor-ri_cal-0.9.0 lib/ri_cal/property_value/utc_offset.rb
ebeigarts-ri_cal-0.8.1 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.10 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.11 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.3 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.4 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.5 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.6 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.7 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.8 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.0.9 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.5.0 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.5.1 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.5.2 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.5.3 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.6.0 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.6.1 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.6.2 lib/ri_cal/property_value/utc_offset.rb
rubyredrick-ri_cal-0.6.3 lib/ri_cal/property_value/utc_offset.rb