Class: Moab::UtcTime

Inherits:
Object
  • Object
show all
Defined in:
lib/moab/utc_time.rb

Overview

Timestamp conversion methods.

Class Method Summary collapse

Class Method Details

.input(datetime) ⇒ void

This method returns an undefined value.

Returns Convert input datetime to a Time object, or nil if input is empty.

Parameters:

  • datetime (Time, String, Nil)

    The input datetime



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/moab/utc_time.rb', line 8

def self.input(datetime)
  case datetime
  when nil
    nil
  when ""
    nil
  when String
    Time.parse(datetime)
  when Time
    datetime
  else
    raise(MoabRuntimeError, "unknown time format #{datetime.inspect}")
  end
end

.output(datetime) ⇒ String

Returns Convert the datetime into a ISO 8601 formatted string.

Parameters:

  • datetime (Time, String, Nil)

    The datetime value to output

Returns:

  • (String)

    Convert the datetime into a ISO 8601 formatted string



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/moab/utc_time.rb', line 25

def self.output(datetime)
  case datetime
  when nil, ""
    ""
  when String
    Time.parse(datetime).utc.iso8601
  when Time
    datetime.utc.iso8601
  else
    raise(MoabRuntimeError, "unknown time format #{datetime.inspect}")
  end
end