Sha256: 3e90643811799d057accbaedf8dcb865564b0091cc1bdb60e56d63aa74db8141

Contents?: true

Size: 350 Bytes

Versions: 3

Compression:

Stored size: 350 Bytes

Contents

require 'chronic'

module Weather
  class Utils

    # Attempts to convert passed text into a Time object
    #
    # Returns a Time object or nil
    def self.parse_time(text = '')
      if text == ''
        return nil
      end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
weather-api-1.4.0 lib/weather-api/utils.rb
weather-api-1.3.0 lib/weather-api/utils.rb
weather-api-1.2.0 lib/weather-api/utils.rb