class Seahorse::Model::Shapes::Timestamp

Attributes

format[R]

@return [String]

Public Class Methods

new(definition, options = {}) click to toggle source
Calls superclass method Seahorse::Model::Shapes::Shape.new
# File lib/seahorse/model/shapes.rb, line 382
def initialize(definition, options = {})
  @format = definition['timestampFormat']
  super
end

Public Instance Methods

format_time(time, default_format) click to toggle source

@param [Time] time @param [String] default_format The format to default to

when {#format} is not set on this timestamp shape.

@return [String]

# File lib/seahorse/model/shapes.rb, line 394
def format_time(time, default_format)
  format = @format || default_format
  case format
  when 'iso8601'       then time.utc.iso8601
  when 'rfc822'        then time.utc.rfc822
  when 'httpdate'      then time.httpdate
  when 'unixTimestamp' then time.utc.to_i
  else
    msg = "invalid timestamp format #{format.inspect}"
    raise ArgumentError, msg
  end
end