Class: Date
- Inherits:
-
Object
- Object
- Date
- Defined in:
- lib/timerizer.rb
Overview
Date class monkey-patched with Timerizer::Duration helpers.
Class Method Summary collapse
-
.tomorrow ⇒ Object
Return tomorrow as Date.
-
.yesterday ⇒ Object
Return yesterday as Date.
Instance Method Summary collapse
-
#at(time) ⇒ Object
Apply a time to a date.
-
#days_in_month ⇒ Integer
Return the number of days in a given month.
-
#to_date ⇒ Object
Return self as Date.
Class Method Details
.tomorrow ⇒ Object
Return tomorrow as Date.
161 162 163 |
# File 'lib/timerizer.rb', line 161 def self.tomorrow 1.day.from_now.to_date end |
.yesterday ⇒ Object
Return yesterday as Date.
167 168 169 |
# File 'lib/timerizer.rb', line 167 def self.yesterday 1.day.ago.to_date end |
Instance Method Details
#at(time) ⇒ Object
Apply a time to a date
155 156 157 |
# File 'lib/timerizer.rb', line 155 def at(time) time.to_wall.on(self) end |
#days_in_month ⇒ Integer
Return the number of days in a given month.
135 136 137 138 139 140 141 142 143 |
# File 'lib/timerizer.rb', line 135 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 ⇒ Object
Return self as Date.
147 148 149 |
# File 'lib/timerizer.rb', line 147 def to_date self end |