module Timely::Date

Public Instance Methods

at(hour = nil, minute = nil, second = nil)
Alias for: at_time
at_time(hour = nil, minute = nil, second = nil) click to toggle source
# File lib/timely/date.rb, line 5
def at_time(hour = nil, minute = nil, second = nil)
  if hour.is_a?(::Time)
    time = hour
    hour = time.hour
    minute = time.min
    second = time.sec
  end

  ::Time.local(year, month, day, hour, minute, second)
end
Also aliased as: at
between?(from, to) click to toggle source

returns true if date between from and to however if from and/or to are nil, it ignores that query e.g. date.between?(from, nil) is “date > from”,

date.between?(from, nil) is "date < to"
date.between?(nil, nil)  is true
# File lib/timely/date.rb, line 23
def between?(from, to)
  from = from.to_date if from && !from.is_a?(Date)
  to   = to.to_date if to && !to.is_a?(Date)

  if from && to
    self >= from && self <= to
  elsif from
    self >= from
  elsif to
    self <= to
  else
    true # i.e. no restrictive range return true
  end
end