Module: Quickbooks::Support::Date

Defined in:
lib/quickbooks/ruby_ext.rb

Class Method Summary collapse

Class Method Details

.new(whatever) ⇒ Object



198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/quickbooks/ruby_ext.rb', line 198

def self.new(whatever)
  case
  when whatever.is_a?(::String)
    ::Date.parse(whatever)
  when whatever.is_a?(::Date)
    whatever
  when whatever.respond_to?(:to_date)
    whatever.to_date
  when whatever.respond_to?(:to_s)
    ::Date.parse(whatever.to_s)
  else
    ::Date.new(whatever)
  end
end