0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-14 13:58:53 +08:00
discourse/plugins/discourse-calendar/app/services/discourse_calendar/holiday.rb
2025-07-15 16:38:05 +02:00

30 lines
697 B
Ruby
Vendored

# 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