Module: DigitalOpera::HolidayCalculations
Instance Method Summary collapse
-
#is_a_holiday? ⇒ Boolean
Returns TRUE || FALSE if the date is a recognized holiday.
-
#is_christmas_day? ⇒ Boolean
(also: #is_xmas_day?)
Christmas Day (December 25th) & Christmas Eve (December 24th) Since these holidays do not change from year to year, we are only providing boolean checks.
- #is_christmas_eve? ⇒ Boolean (also: #is_xmas_eve?)
-
#is_fourth_of_july? ⇒ Boolean
July 4th Since this holiday does not change we are only providing boolean checks.
- #is_labor_day? ⇒ Boolean
- #is_memorial_day? ⇒ Boolean
-
#is_new_years_day? ⇒ Boolean
New Years Day (January 1st) Since this holiday does not change, it is always January 1st, we are only providing boolean checks.
-
#is_not_a_holiday? ⇒ Boolean
Returns TRUE || FALSE if the date IS NOT a recognized holiday.
- #is_not_christmas_day? ⇒ Boolean (also: #is_not_xmas_day?)
- #is_not_christmas_eve? ⇒ Boolean (also: #is_not_xmas_eve?)
- #is_not_fourth_of_july? ⇒ Boolean
- #is_not_labor_day? ⇒ Boolean
- #is_not_memorial_day? ⇒ Boolean
- #is_not_new_years_day? ⇒ Boolean
- #is_not_thanksgiving_day? ⇒ Boolean
- #is_thanksgiving_day? ⇒ Boolean
-
#labor_day_this_year ⇒ Object
Labor Day (First monday in september) en.wikipedia.org/wiki/Labor_Day.
-
#memorial_day_this_year ⇒ Object
Memorial Day (Last monday in may) en.wikipedia.org/wiki/Memorial_Day.
-
#thanksgiving_day_this_year ⇒ Object
Thanksgiving Day (fourth thursday in november in the US) en.wikipedia.org/wiki/Thanksgiving.
Instance Method Details
#is_a_holiday? ⇒ Boolean
Returns TRUE || FALSE if the date is a recognized holiday
10 11 12 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 10 def is_a_holiday? self.is_memorial_day? || self.is_labor_day? || self.is_thanksgiving_day? || self.is_new_years_day? || self.is_xmas_day? || self.is_xmas_eve? || self.is_fourth_of_july? end |
#is_christmas_day? ⇒ Boolean Also known as: is_xmas_day?
Christmas Day (December 25th) & Christmas Eve (December 24th) Since these holidays do not change from year to year, we are only providing boolean checks
87 88 89 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 87 def is_christmas_day? self.month == 12 && self.mday == 25 end |
#is_christmas_eve? ⇒ Boolean Also known as: is_xmas_eve?
97 98 99 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 97 def is_christmas_eve? self.month == 12 && self.mday == 24 end |
#is_fourth_of_july? ⇒ Boolean
July 4th Since this holiday does not change we are only providing boolean checks
122 123 124 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 122 def is_fourth_of_july? self.month == 7 && self.mday == 4 end |
#is_labor_day? ⇒ Boolean
33 34 35 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 33 def is_labor_day? self == self.labor_day_this_year end |
#is_memorial_day? ⇒ Boolean
54 55 56 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 54 def is_memorial_day? self == self.memorial_day_this_year end |
#is_new_years_day? ⇒ Boolean
New Years Day (January 1st) Since this holiday does not change, it is always January 1st, we are only providing boolean checks
111 112 113 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 111 def is_new_years_day? self.yday == 1 end |
#is_not_a_holiday? ⇒ Boolean
Returns TRUE || FALSE if the date IS NOT a recognized holiday
16 17 18 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 16 def is_not_a_holiday? self.is_not_memorial_day? && self.is_not_labor_day? && self.is_not_thanksgiving_day? && self.is_not_new_years_day? && self.is_not_xmas_day? && self.is_not_xmas_eve? && self.is_not_fourth_of_july? end |
#is_not_christmas_day? ⇒ Boolean Also known as: is_not_xmas_day?
92 93 94 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 92 def is_not_christmas_day? self.month != 12 || self.mday != 25 end |
#is_not_christmas_eve? ⇒ Boolean Also known as: is_not_xmas_eve?
102 103 104 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 102 def is_not_christmas_eve? self.month != 12 || self.mday != 24 end |
#is_not_fourth_of_july? ⇒ Boolean
126 127 128 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 126 def is_not_fourth_of_july? self.month != 7 || self.mday != 4 end |
#is_not_labor_day? ⇒ Boolean
37 38 39 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 37 def is_not_labor_day? self != self.labor_day_this_year end |
#is_not_memorial_day? ⇒ Boolean
58 59 60 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 58 def is_not_memorial_day? self != self.memorial_day_this_year end |
#is_not_new_years_day? ⇒ Boolean
115 116 117 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 115 def is_not_new_years_day? self.yday != 1 end |
#is_not_thanksgiving_day? ⇒ Boolean
79 80 81 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 79 def is_not_thanksgiving_day? self != self.thanksgiving_day_this_year end |
#is_thanksgiving_day? ⇒ Boolean
75 76 77 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 75 def is_thanksgiving_day? self == self.thanksgiving_day_this_year end |
#labor_day_this_year ⇒ Object
Labor Day (First monday in september) en.wikipedia.org/wiki/Labor_Day
23 24 25 26 27 28 29 30 31 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 23 def labor_day_this_year september = Date.parse("01/09/#{self.year}") labor_day = september.beginning_of_month.step(september.end_of_month, 1).map{ |day| day if day.monday? }.compact.first if self.class.name == "Time" return labor_day.to_time else return labor_day end end |
#memorial_day_this_year ⇒ Object
Memorial Day (Last monday in may) en.wikipedia.org/wiki/Memorial_Day
44 45 46 47 48 49 50 51 52 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 44 def memorial_day_this_year may = Date.parse("01/05/#{self.year}") memorial_day = may.beginning_of_month.step(may.end_of_month, 1).map{ |day| day if day.monday? }.compact.last if self.class.name == "Time" return memorial_day.to_time else return memorial_day end end |
#thanksgiving_day_this_year ⇒ Object
Thanksgiving Day (fourth thursday in november in the US) en.wikipedia.org/wiki/Thanksgiving
65 66 67 68 69 70 71 72 73 |
# File 'lib/is_business_day/digitalopera/holiday_calculations.rb', line 65 def thanksgiving_day_this_year november = Date.parse("01/11/#{self.year}") thanksgiving_day = november.beginning_of_month.step(november.end_of_month, 1).map{ |day| day if day.thursday? }.compact.fourth if self.class.name == "Time" return thanksgiving_day.to_time else return thanksgiving_day end end |