Sha256: 5031ad57094eceb7de48028628bc2d070bf8a774db68a69841c2b9f104e9e926

Contents?: true

Size: 521 Bytes

Versions: 2

Compression:

Stored size: 521 Bytes

Contents

module Quandl
  module Operation
    class QDate
      class << self
        def parse(value)
          date = Date.jd(value.to_i) if value.is_a?(String) && value.numeric?
          date = Date.jd(value) if value.is_a?(Integer)
          date = Date.parse(value) if value.is_a?(String) && value =~ /^[0-9]{4}\-[0-9]{2}\-[0-9]{2}$/
          date = value if value.is_a?(Date)
          date = value.to_date if value.respond_to?(:to_date)
          date
        rescue
          nil
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
quandl_operation-0.4.2 lib/quandl/operation/qdate.rb
quandl_operation-0.4.2.rc1 lib/quandl/operation/qdate.rb