Module: OpenHAB::CoreExt::Ephemeris
- Included in:
- Date, DateTime, Java::LocalDate, Java::MonthDay, Time
- Defined in:
- lib/openhab/core_ext/ephemeris.rb
Overview
openHAB's built-in holiday definitions are based on bank holidays, so may give some unexpected results. For example, 2022-12-25 is not Christmas in England because it lands on a Sunday that year, so Christmas is considered to be 2022-12-26. See the source for exact definitions. You can always provide your own holiday definitions with holiday_file or holiday_file!.
Forwards ephemeris helper methods to #to_zoned_date_time
provided by
the mixed-in class.
Instance Method Summary collapse
-
#days_until(holiday, holiday_file = nil) ⇒ Integer
Calculate the number of days until a specific holiday.
-
#holiday(holiday_file = nil) ⇒ Symbol?
Name of the holiday for this date.
-
#holiday?(holiday_file = nil) ⇒ true, false
Determines if this date is on a holiday.
-
#in_dayset?(set) ⇒ true, false
Determines if this time is during a specific dayset.
-
#next_holiday(holiday_file = nil) ⇒ Symbol
Name of the closest holiday on or after this date.
-
#weekend? ⇒ true, false
Determines if this time is during a weekend.
Instance Method Details
#days_until(holiday, holiday_file = nil) ⇒ Integer
Calculate the number of days until a specific holiday
48 49 50 |
# File 'lib/openhab/core_ext/ephemeris.rb', line 48 def days_until(holiday, holiday_file = nil) to_zoned_date_time.days_until(holiday, holiday_file) end |
#holiday(holiday_file = nil) ⇒ Symbol?
Name of the holiday for this date.
23 24 25 |
# File 'lib/openhab/core_ext/ephemeris.rb', line 23 def holiday(holiday_file = nil) to_zoned_date_time.holiday(holiday_file) end |
#holiday?(holiday_file = nil) ⇒ true, false
Determines if this date is on a holiday.
28 29 30 |
# File 'lib/openhab/core_ext/ephemeris.rb', line 28 def holiday?(holiday_file = nil) to_zoned_date_time.holiday?(holiday_file) end |
#in_dayset?(set) ⇒ true, false
Determines if this time is during a specific dayset
43 44 45 |
# File 'lib/openhab/core_ext/ephemeris.rb', line 43 def in_dayset?(set) to_zoned_date_time.in_dayset?(set) end |
#next_holiday(holiday_file = nil) ⇒ Symbol
Name of the closest holiday on or after this date.
33 34 35 |
# File 'lib/openhab/core_ext/ephemeris.rb', line 33 def next_holiday(holiday_file = nil) to_zoned_date_time.next_holiday(holiday_file) end |
#weekend? ⇒ true, false
Determines if this time is during a weekend.
38 39 40 |
# File 'lib/openhab/core_ext/ephemeris.rb', line 38 def weekend? to_zoned_date_time.weekend? end |