module RichUnits::Times::TimeClass
Time
Metaclass Extensions¶ ↑
Public Instance Methods
days_extrema(time1, time2=nil)
click to toggle source
This method calculates the days extrema given two time objects.
start time is the given time1 at 00:00:00 end time is the given time2 at 23:59:59:999
Input:
-
the two times (if only time1 is provided then you get an extrema of exactly one day extrema.
Output:
-
the time range. you can get the start/end times using range methods.
CREDIT George Moschovitis
# File lib/richunits/times.rb, line 410 def days_extrema(time1, time2=nil) time2 = time1 if (not time2.valid? Time) time2 = NEVER if (time2 <= time1) start_time = time1.start_of_day #start_of_day(time1) end_time = time2.end_of_day #end_of_day(time2) return (start_time..end_time) end