Class: DateTime

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

Overview

A DateTime can be constructed from any Date or DateTime subclass, or parsed from a String

Class Method Summary collapse

Class Method Details

.new_instance(constellation, *a, &b) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/activefacts/api/date.rb', line 39

def self.new_instance constellation, *a, &b
  if a[0].is_a?(String)
    dt = parse(*a)
  elsif (a.size == 1)
    case a[0]
    when DateTime
      dt = civil(a[0].year, a[0].month, a[0].day, a[0].hour, a[0].min, a[0].sec, a[0].start)
    when Date
      dt = civil(a[0].year, a[0].month, a[0].day, 0, 0, 0, a[0].start)
    when NilClass
      dt = civil()
    else
      dt = civil(*a, &b)
    end
  else
    dt = civil(*a, &b)
  end
  dt.send(:instance_variable_set, :@constellation, constellation)
  dt
end