Module: CalendariumRomanum::Temporale::DateHelper
- Extended by:
- DateHelper
- Included in:
- DateHelper, Dates
- Defined in:
- lib/calendarium-romanum/temporale/date_helper.rb
Overview
Provides utility methods for date arithmetics, available both as mixin instance methods and module methods.
Constant Summary collapse
- WEEKDAYS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
%w(sunday monday tuesday wednesday thursday friday saturday).freeze
Instance Method Summary collapse
- #friday_after(date) ⇒ Object
- #friday_before(date) ⇒ Object
- #monday_after(date) ⇒ Object
- #monday_before(date) ⇒ Object
- #octave_of(date) ⇒ Date
- #saturday_after(date) ⇒ Object
- #saturday_before(date) ⇒ Object
- #sunday_after(date) ⇒ Date
- #sunday_before(date) ⇒ Date
- #thursday_after(date) ⇒ Object
- #thursday_before(date) ⇒ Object
- #tuesday_after(date) ⇒ Object
- #tuesday_before(date) ⇒ Object
- #wednesday_after(date) ⇒ Object
- #wednesday_before(date) ⇒ Object
- #weekday_after(weekday, date) ⇒ Date
- #weekday_before(weekday, date) ⇒ Date
Instance Method Details
#friday_after(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 56
|
#friday_before(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 40
|
#monday_after(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 56
|
#monday_before(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 40
|
#octave_of(date) ⇒ Date
36 37 38 |
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 36 def octave_of(date) date + WEEK end |
#saturday_after(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 56
|
#saturday_before(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 40
|
#sunday_after(date) ⇒ Date
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 56
|
#sunday_before(date) ⇒ Date
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 40
|
#thursday_after(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 56
|
#thursday_before(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 40
|
#tuesday_after(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 56
|
#tuesday_before(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 40
|
#wednesday_after(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 56
|
#wednesday_before(date) ⇒ Object
|
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 40
|
#weekday_after(weekday, date) ⇒ Date
24 25 26 27 28 29 30 31 32 |
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 24 def weekday_after(weekday, date) if date.wday == weekday date + WEEK elsif weekday > date.wday date + (weekday - date.wday) else date + (WEEK - date.wday + weekday) end end |
#weekday_before(weekday, date) ⇒ Date
13 14 15 16 17 18 19 20 21 |
# File 'lib/calendarium-romanum/temporale/date_helper.rb', line 13 def weekday_before(weekday, date) if date.wday == weekday date - WEEK elsif weekday < date.wday date - (date.wday - weekday) else date - (date.wday + WEEK - weekday) end end |