Sha256: 4a855479608d4ff44a83931c670c5e8d116a2166453e00222ca6dd29424786fa

Contents?: true

Size: 456 Bytes

Versions: 2

Compression:

Stored size: 456 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

  def blank?
    false
  end

  private
  def utc_hours_offset
    self.offset * 24
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rcap-2.4.1 lib/rcap/extensions/date_time.rb
rcap-2.4.0 lib/rcap/extensions/date_time.rb