Module: UkWorkingDays::DateExtensions::ClassMethods
- Included in:
- Date
- Defined in:
- lib/uk_working_days/date_extensions.rb
Instance Method Summary collapse
-
#boxing_day_holiday(year) ⇒ Object
Boxing day, or the next working day following.
-
#christmas_day_holiday(year) ⇒ Object
Christmas day, or the next weekday following if on a weekend.
-
#easter_monday(year) ⇒ Object
The monday after Easter Sunday.
-
#good_friday(year) ⇒ Object
The friday before Easter Sunday.
-
#may_bank_holiday(year) ⇒ Object
The first monday in May.
-
#new_years_day_holiday(year) ⇒ Object
New year’s day, or the next weekday following if on a weekend.
-
#public_holidays(year) ⇒ Object
An Array of all public holidays for the given year.
-
#spring_bank_holiday(year) ⇒ Object
The last monday in May.
-
#summer_bank_holiday(year) ⇒ Object
The last monday in August.
Instance Method Details
#boxing_day_holiday(year) ⇒ Object
Boxing day, or the next working day following
58 59 60 |
# File 'lib/uk_working_days/date_extensions.rb', line 58 def boxing_day_holiday(year) ([0,5,6].include? christmas_day_holiday(year).wday) ? christmas_day_holiday(year).next_week : christmas_day_holiday(year).tomorrow end |
#christmas_day_holiday(year) ⇒ Object
Christmas day, or the next weekday following if on a weekend
52 53 54 55 |
# File 'lib/uk_working_days/date_extensions.rb', line 52 def christmas_day_holiday(year) xmas_day = new(year, 12, 25) xmas_day.weekday? ? xmas_day : xmas_day.next_week end |
#easter_monday(year) ⇒ Object
The monday after Easter Sunday
63 64 65 |
# File 'lib/uk_working_days/date_extensions.rb', line 63 def easter_monday(year) easter(year) + 1 end |
#good_friday(year) ⇒ Object
The friday before Easter Sunday
68 69 70 |
# File 'lib/uk_working_days/date_extensions.rb', line 68 def good_friday(year) easter(year) - 2 end |
#may_bank_holiday(year) ⇒ Object
The first monday in May
73 74 75 76 |
# File 'lib/uk_working_days/date_extensions.rb', line 73 def may_bank_holiday(year) first_day_may = new(year, 5, 1) first_day_may.wday == 1 ? first_day_may : first_day_may.next_week end |
#new_years_day_holiday(year) ⇒ Object
New year’s day, or the next weekday following if on a weekend
46 47 48 49 |
# File 'lib/uk_working_days/date_extensions.rb', line 46 def new_years_day_holiday(year) nyd = new(year, 1, 1) nyd.weekday?() ? nyd : nyd.next_week end |
#public_holidays(year) ⇒ Object
An Array of all public holidays for the given year
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/uk_working_days/date_extensions.rb', line 89 def public_holidays(year) [new_years_day_holiday(year), good_friday(year), easter_monday(year), may_bank_holiday(year), spring_bank_holiday(year), summer_bank_holiday(year), christmas_day_holiday(year), boxing_day_holiday(year)] end |
#spring_bank_holiday(year) ⇒ Object
The last monday in May
79 80 81 |
# File 'lib/uk_working_days/date_extensions.rb', line 79 def spring_bank_holiday(year) new(year, 5, 31).beginning_of_week end |
#summer_bank_holiday(year) ⇒ Object
The last monday in August
84 85 86 |
# File 'lib/uk_working_days/date_extensions.rb', line 84 def summer_bank_holiday(year) new(year, 8, 31).beginning_of_week end |