Class: DateTime
- Inherits:
-
Object
- Object
- DateTime
- Defined in:
- lib/date/constructor.rb
Overview
Allow a DateTime to be constructed from any Date or DateTime subclass, or parsed from a String
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(*a, &b) ⇒ DateTime
constructor
A new instance of DateTime.
Constructor Details
#initialize(*a, &b) ⇒ DateTime
Returns a new instance of DateTime.
31 32 33 |
# File 'lib/date/constructor.rb', line 31 def initialize *a, &b marshal_load(self.class.new(*a, &b).marshal_dump) end |
Class Method Details
.new(*a, &b) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# 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 |