Class: Weather::Utils

Inherits:
Object
  • Object
show all
Defined in:
lib/weather-api/utils.rb

Class Method Summary collapse

Class Method Details

.parse_time(text = '') ⇒ Object

Attempts to convert passed text into a Time object

Returns a Time object or nil



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/weather-api/utils.rb', line 9

def self.parse_time(text = '')
  if text == ''
    return nil
  end

  begin
    Time.parse text
  rescue ArgumentError
    Chronic.parse text
  end
end