Sha256: af2f10b39c81e7f15adf70fc293d397bd158e1bb87394fbb88966e0f9f0281e0

Contents?: true

Size: 451 Bytes

Versions: 4

Compression:

Stored size: 451 Bytes

Contents

class DateTime
  alias_method :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 = 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
    offset * 24
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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