Files
discourse/plugins/discourse-events/app/services/discourse_calendar/holiday.rb
T
David Battersby 629c919eb2 DEV: rename Discourse Calendar to Discourse Events (#42021)
Moves the plugin directory and associated files, along with updating
various import references.
2026-08-12 11:34:15 +04:00

31 lines
697 B
Ruby

# frozen_string_literal: true
require "holidays"
module DiscourseCalendar
class Holiday
def self.find_holidays_for(
region_code:,
start_date: Date.current.beginning_of_year,
end_date: Date.current.end_of_year,
show_holiday_observed_on_dates: false
)
holidays =
Holidays.between(
start_date,
end_date,
[region_code],
show_holiday_observed_on_dates ? :observed : [],
)
holidays.map do |holiday|
holiday[:disabled] = DiscourseCalendar::DisabledHoliday.where(
region_code: region_code,
).exists?(holiday_name: holiday[:name])
end
holidays
end
end
end