class Date
{Date} class monkey-patched with {Timerizer::Duration} helpers.
Public Class Methods
tomorrow()
click to toggle source
Return tomorrow as {Date}. @see Date#yesterday
# File lib/timerizer.rb, line 164 def self.tomorrow 1.day.from_now.to_date end
yesterday()
click to toggle source
Return yesterday as {Date}. @see Date#tomorrow
# File lib/timerizer.rb, line 170 def self.yesterday 1.day.ago.to_date end
Public Instance Methods
at(time)
click to toggle source
Apply a time to a date @example yesterday at 5:00
Date.yesterday.at(WallClock.new(5, 00, :pm)) => 2000-1-1 17:00:00 -0800
# File lib/timerizer.rb, line 158 def at(time) time.to_wall.on(self) end
days_in_month()
click to toggle source
Return the number of days in a given month. @return [Integer] Number of days in the month of the {Date}. @example
Date.new(2000, 2).days_in_month => 29
# File lib/timerizer.rb, line 137 def days_in_month days_in_feb = (not self.leap?) ? 28 : 29 number_of_days = [ 31, days_in_feb, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ] number_of_days.fetch(self.month - 1) end
to_date()
click to toggle source
Return self as {Date}. @see Time#to_date
# File lib/timerizer.rb, line 150 def to_date self end