Class: TicketEvolution::Time

Inherits:
Time
  • Object
show all
Defined in:
lib/ticket_evolution/core/time.rb

Class Method Summary collapse

Class Method Details

.parse(str) ⇒ Object



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

def self.parse(str)
  if str =~ /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/
    parts = str.split(/[-T:Z]/).collect(&:to_i)
    Time.gm(
      parts[0],
      parts[1],
      parts[2],
      parts[3],
      parts[4],
      parts[5]
    )
  else
    str
  end
end