Class: DateTime

Inherits:
Object
  • Object
show all
Defined in:
lib/activefacts/api/numeric.rb

Overview

A DateTime can be constructed from any Date or DateTime subclass

Class Method Summary collapse

Class Method Details

.new(*a, &b) ⇒ Object

DateTime.new cannot normally be called passing a Date or DateTime as the parameter. This allows that.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/activefacts/api/numeric.rb', line 89

def self.new(*a, &b)
  #puts "Constructing DateTime with #{a.inspect} from #{caller*"\n\t"}"
  if (a.size == 1)
    a = a[0]
    if (DateTime === a)
      civil(a.year, a.month, a.day, a.hour, a.min, a.sec, a.start)
    elsif (Date === a)
      civil(a.year, a.month, a.day, a.start)
    else
      civil(*a, &b)
    end
  else
    civil(*a, &b)
  end
end

.old_newObject



87
# File 'lib/activefacts/api/numeric.rb', line 87

alias_method :old_new, :new