Class: GandiV5::Data::Converter::Time

Inherits:
Object
  • Object
show all
Defined in:
lib/gandi_v5/data/converter/time.rb

Overview

Methods for converting times to/from Gandi (“2019-02-13T11:04:18Z”).

Class Method Summary collapse

Class Method Details

.from_gandi(value) ⇒ Object

Convert a time from Gandi’s prefered string format.

Parameters:

  • (String)


20
21
22
23
24
# File 'lib/gandi_v5/data/converter/time.rb', line 20

def self.from_gandi(value)
  return nil if value.nil?

  ::Time.parse value
end

.to_gandi(value) ⇒ String

Convert a time to Gandi’s prefered string format.

Parameters:

Returns:

  • (String)


11
12
13
14
15
# File 'lib/gandi_v5/data/converter/time.rb', line 11

def self.to_gandi(value)
  return nil if value.nil?

  value.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
end