Sha256: 26d407e34b052cda89ac1e48aff0360530274807c31601c5bda9ba4dddb3b0d2

Contents?: true

Size: 397 Bytes

Versions: 4

Compression:

Stored size: 397 Bytes

Contents

class Time
  # Returns a string representaion of the time suitable for CAP.
  # @return [String]
  # @example
  #   Time.now.to_s_for_cap # => "2011-10-26T21:45:00+02:00"
  def to_s_for_cap
    t = strftime(RCAP::RCAP_TIME_FORMAT) + format(RCAP::RCAP_ZONE_FORMAT, utc_hours_offset)
    t.sub(/\+(00:\d\d)$/, '-\1')
  end

  private
  def utc_hours_offset
    localtime.utc_offset / 3600
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rcap-2.7.0 lib/rcap/extensions/time.rb
rcap-2.6.0 lib/rcap/extensions/time.rb
rcap-2.5.1 lib/rcap/extensions/time.rb
rcap-2.5.0 lib/rcap/extensions/time.rb