lib/viewpoint/string_utils.rb
def iso8601_duration_to_seconds(input)
      return nil if input.nil? || input.empty?
      match_data = DURATION_RE.match(input)
      raise(StringFormatException, "Invalid duration given") if match_data.nil?
      duration = 0
      duration += match_data[:weeks].to_i   * 604800
      duration += match_data[:days].to_i    * 86400
      duration += match_data[:hours].to_i   * 3600
      duration += match_data[:minutes].to_i * 60
      duration += match_data[:seconds].to_i
    end
def iso8601_duration_to_seconds(input)
      return nil if input.nil? || input.empty?
      match_data = DURATION_RE.match(input)
      raise(StringFormatException, "Invalid duration given") if match_data.nil?
      duration = 0
      duration += match_data[:weeks].to_i   * 604800
      duration += match_data[:days].to_i    * 86400
      duration += match_data[:hours].to_i   * 3600
      duration += match_data[:minutes].to_i * 60
      duration += match_data[:seconds].to_i
    end
def iso8601_duration_to_seconds ( input ) return nil if input . nil? || input . empty? match_data = DURATION_RE . match ( input ) raise ( StringFormatException , "Invalid duration given" ) if match_data . nil? duration = 0 duration += match_data [ :weeks ] . to_i * 604800 duration += match_data [ :days ] . to_i * 86400 duration += match_data [ :hours ] . to_i * 3600 duration += match_data [ :minutes ] . to_i * 60 duration += match_data [ :seconds ] . to_i end
Convert an ISO8601 Duration format to seconds
 @see http://tools.ietf.org/html/rfc2445#section-4.3.6
 @param [String] input
 @return [nil,Fixnum] the number of seconds in this duration
   nil if there is no known duration
Convert an ISO8601 Duration format to seconds