Sha256: 6bc5509c8fdda90a45f18346f5ce6fe32e7569f65b7f92ac5c0f57d5087dfd56

Contents?: true

Size: 349 Bytes

Versions: 2

Compression:

Stored size: 349 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

2 entries across 2 versions & 1 rubygems

Version Path
weather-api-1.1.1 lib/weather-api/utils.rb
weather-api-1.1.0 lib/weather-api/utils.rb