Module: Tod

Defined in:
lib/tod/shift.rb,
lib/tod/version.rb,
lib/tod/time_of_day.rb,
lib/tod/conversions.rb,
lib/tod/mongoization.rb,
lib/tod/mongoization.rb,
lib/tod/time_extensions.rb,
lib/tod/date_extensions.rb

Defined Under Namespace

Modules: DateExtensions, Mongoization, TimeExtensions Classes: Shift, TimeOfDay

Constant Summary collapse

VERSION =
"2.0.2"

Class Method Summary collapse

Class Method Details

.TimeOfDay(obj_or_string) ⇒ Object


2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/tod/conversions.rb', line 2

def TimeOfDay(obj_or_string)
  if obj_or_string.is_a?(TimeOfDay)
    obj_or_string
  elsif obj_or_string.respond_to?(:to_time_of_day)
    obj_or_string.to_time_of_day
  elsif obj_or_string.respond_to?(:hour) && obj_or_string.respond_to?(:min) && obj_or_string.respond_to?(:sec)
    TimeOfDay.new obj_or_string.hour, obj_or_string.min, obj_or_string.sec
  elsif obj_or_string.is_a?(Date)
    TimeOfDay.new 0
  else
    TimeOfDay.parse(obj_or_string)
  end
end