Class: Time

Inherits:
Object
  • Object
show all
Defined in:
motion/core/time.rb

Class Method Summary collapse

Class Method Details

.iso8601(time) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'motion/core/time.rb', line 3

def self.iso8601(time)
  if time.include?(".")
    # Fractional Seconds
    if time.include?('Z')
      iso8601_with_fractional_seconds(time)
    else
      iso8601_with_fractional_seconds_and_timesone(time)
    end
  else
    # Non Fractional Seconds
    if time.include?('Z')
      iso8601_zulu(time)
    else
      iso8601_with_timezone(time)
    end
  end
end

.iso8601_with_fractional_seconds(time) ⇒ Object



31
32
33
34
# File 'motion/core/time.rb', line 31

def self.iso8601_with_fractional_seconds(time)
  cached_date_formatter("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").
    dateFromString(time)
end

.iso8601_with_fractional_seconds_and_timesone(time) ⇒ Object



36
37
38
39
# File 'motion/core/time.rb', line 36

def self.iso8601_with_fractional_seconds_and_timesone(time)
  cached_date_formatter("yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ").
    dateFromString(time)
end

.iso8601_with_timezone(time) ⇒ Object



26
27
28
29
# File 'motion/core/time.rb', line 26

def self.iso8601_with_timezone(time)
  cached_date_formatter("yyyy-MM-dd'T'HH:mm:ssZZZZZ").
    dateFromString(time)
end

.iso8601_zulu(time) ⇒ Object



21
22
23
24
# File 'motion/core/time.rb', line 21

def self.iso8601_zulu(time)
  cached_date_formatter("yyyy-MM-dd'T'HH:mm:ss'Z'").
    dateFromString(time)
end