Sha256: 40bffd260ba17a09da180704f28121f0c49c21f94ce85666fd4f598518f63ea6

Contents?: true

Size: 411 Bytes

Versions: 9

Compression:

Stored size: 411 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 = self.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
    self.localtime.utc_offset/3600
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rcap-2.4.1 lib/rcap/extensions/time.rb
rcap-2.4.0 lib/rcap/extensions/time.rb
rcap-2.3.0 lib/rcap/extensions/time.rb
rcap-2.2.1 lib/rcap/extensions/time.rb
rcap-2.2.0 lib/rcap/extensions/time.rb
rcap-2.1.0 lib/rcap/extensions/time.rb
rcap-2.0.2 lib/rcap/extensions/time.rb
rcap-2.0.1 lib/rcap/extensions/time.rb
rcap-2.0.0 lib/rcap/extensions/time.rb