Module: Kagemusha::DateTime
- Defined in:
- lib/kagemusha/datetime.rb
Overview
:nodoc:
Class Method Summary collapse
Class Method Details
.at(time_or_year, mon = 1, mday = 1, hour = 0, min = 0, sec = 0, &block) ⇒ Object
:nodoc:
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kagemusha/datetime.rb', line 14 def self.at(time_or_year, mon = 1, mday = 1, hour = 0, min = 0, sec = 0, &block) if block_given? return self.at(time_or_year, mon, mday, hour, min, sec).swap(&block) end case time_or_year when ::Time time = time_or_year date = ::Date.new(time.year, time.mon, time.mday) when ::Date date = time_or_year time = ::Time.local(date.year, date.mon, date.mday) when ::Integer time = ::Time.local(time_or_year, mon, mday, hour, min, sec) date = ::Date.new(time_or_year, mon, mday) else raise(ArgumentError, "?") # FIXME: message end datemusha = Kagemusha::Date.on(date) timemusha = Kagemusha::Time.at(time) return datemusha + timemusha end |