Sha256: e39705fe5bee48babb2f5b2d9b6000f34177f8274ea36de60bde219763850457

Contents?: true

Size: 473 Bytes

Versions: 1

Compression:

Stored size: 473 Bytes

Contents

class Time
  RCAP_TIME_FORMAT = "%Y-%m-%dT%H:%M:%S"
  RCAP_ZONE_FORMAT = "%+03i:00"

  # 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_TIME_FORMAT ) + format( 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

1 entries across 1 versions & 1 rubygems

Version Path
rcap-1.3.1 lib/extensions/time.rb