Sha256: 3b0f6864a763eedf2012262b3857f07803460779a22448cbc2e32d67799546b1

Contents?: true

Size: 426 Bytes

Versions: 7

Compression:

Stored size: 426 Bytes

Contents

class DateTime
  alias inspect to_s

  # Returns a string representaion of the time suitable for CAP.
  # @return [String]
  # @example
  #   DateTime.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.offset * 24
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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