Class: Quandl::Operation::QDate

Inherits:
Object
  • Object
show all
Defined in:
lib/quandl/operation/qdate.rb

Class Method Summary collapse

Class Method Details

.parse(value) ⇒ Object



7
8
9
10
11
12
13
14
15
16
# File 'lib/quandl/operation/qdate.rb', line 7

def parse(value)
  date = Date.jd(value.to_i) if value.kind_of?(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