Class: Trello::Schema::Serializer::Time

Inherits:
Object
  • Object
show all
Defined in:
lib/trello/schema/serializer/time.rb

Class Method Summary collapse

Class Method Details

.deserialize(time, default) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/trello/schema/serializer/time.rb', line 12

def deserialize(time, default)
  if time.is_a?(String)
    ::Time.iso8601(time) rescue default
  elsif time.respond_to?(:to_time)
    time.to_time
  else
    default
  end
end

.serialize(time) ⇒ Object



6
7
8
9
10
# File 'lib/trello/schema/serializer/time.rb', line 6

def serialize(time)
  return nil unless time.respond_to?(:iso8601)

  time.strftime('%FT%T.%LZ')
end