class DateTime
Allow a DateTime
to be constructed from any Date
or DateTime
subclass, or parsed from a String
Public Class Methods
new(*a, &b)
click to toggle source
# File lib/date/constructor.rb, line 31 def initialize *a, &b marshal_load(self.class.new(*a, &b).marshal_dump) end
new(*a, &b)
click to toggle source
# File lib/date/constructor.rb, line 35 def self.new *a, &b if a[0].is_a?(String) parse(*a) elsif (a.size == 1) case a[0] when DateTime a[0].clone when Date civil(a[0].year, a[0].month, a[0].day, 0, 0, 0, a[0].start) else civil(*a, &b) end else civil(*a, &b) end end