Add Foundation Day holiday for Saudi Arabia (#388)

Foundation Day (Feb 22nd) is a public holiday in Saudi Arabia per: https://holidayapi.com/holidays/sa/foundation-day.
This commit is contained in:
Osama Sayegh 2023-02-20 06:17:28 +03:00 committed by GitHub
parent 19a75f31c6
commit aba5e6dba8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 34 deletions

View File

@ -138,11 +138,11 @@ export const HOLIDAY_REGIONS = [
"hu", "hu",
"id", "id",
"ie", "ie",
"in",
"in_gj",
"in_mh",
"in_rj",
"in_tn", "in_tn",
"in",
"in_rj",
"in_mh",
"in_gj",
"is", "is",
"it", "it",
"it_ve", "it_ve",
@ -300,6 +300,7 @@ export const TIME_ZONE_TO_REGION = {
"America/Caracas": "ve", "America/Caracas": "ve",
"America/Chicago": "us", "America/Chicago": "us",
"America/Chihuahua": "mx", "America/Chihuahua": "mx",
"America/Ciudad_Juarez": "mx",
"America/Costa_Rica": "cr", "America/Costa_Rica": "cr",
"America/Creston": "ca", "America/Creston": "ca",
"America/Cuiaba": "br", "America/Cuiaba": "br",
@ -341,18 +342,15 @@ export const TIME_ZONE_TO_REGION = {
"America/Moncton": "ca", "America/Moncton": "ca",
"America/Monterrey": "mx", "America/Monterrey": "mx",
"America/New_York": "us", "America/New_York": "us",
"America/Nipigon": "ca",
"America/Nome": "us", "America/Nome": "us",
"America/Noronha": "br", "America/Noronha": "br",
"America/North_Dakota/Beulah": "us", "America/North_Dakota/Beulah": "us",
"America/North_Dakota/Center": "us", "America/North_Dakota/Center": "us",
"America/North_Dakota/New_Salem": "us", "America/North_Dakota/New_Salem": "us",
"America/Ojinaga": "mx", "America/Ojinaga": "mx",
"America/Pangnirtung": "ca",
"America/Phoenix": "us", "America/Phoenix": "us",
"America/Porto_Velho": "br", "America/Porto_Velho": "br",
"America/Punta_Arenas": "cl", "America/Punta_Arenas": "cl",
"America/Rainy_River": "ca",
"America/Rankin_Inlet": "ca", "America/Rankin_Inlet": "ca",
"America/Recife": "br", "America/Recife": "br",
"America/Regina": "ca", "America/Regina": "ca",
@ -365,7 +363,6 @@ export const TIME_ZONE_TO_REGION = {
"America/St_Johns": "ca", "America/St_Johns": "ca",
"America/St_Thomas": "vi", "America/St_Thomas": "vi",
"America/Swift_Current": "ca", "America/Swift_Current": "ca",
"America/Thunder_Bay": "ca",
"America/Tijuana": "mx", "America/Tijuana": "mx",
"America/Toronto": "ca", "America/Toronto": "ca",
"America/Vancouver": "ca", "America/Vancouver": "ca",
@ -464,14 +461,12 @@ export const TIME_ZONE_TO_REGION = {
"Europe/Stockholm": "se", "Europe/Stockholm": "se",
"Europe/Tallinn": "ee", "Europe/Tallinn": "ee",
"Europe/Ulyanovsk": "ru", "Europe/Ulyanovsk": "ru",
"Europe/Uzhgorod": "ua",
"Europe/Vaduz": "li", "Europe/Vaduz": "li",
"Europe/Vienna": "at", "Europe/Vienna": "at",
"Europe/Vilnius": "lt", "Europe/Vilnius": "lt",
"Europe/Volgograd": "ru", "Europe/Volgograd": "ru",
"Europe/Warsaw": "pl", "Europe/Warsaw": "pl",
"Europe/Zagreb": "hr", "Europe/Zagreb": "hr",
"Europe/Zaporozhye": "ua",
"Europe/Zurich": "ch", "Europe/Zurich": "ch",
"Pacific/Auckland": "nz", "Pacific/Auckland": "nz",
"Pacific/Chatham": "nz", "Pacific/Chatham": "nz",

View File

@ -5,30 +5,23 @@ require "rails_helper"
module DiscourseCalendar module DiscourseCalendar
describe Holiday do describe Holiday do
describe ".find_holidays_for" do describe ".find_holidays_for" do
before do before { DisabledHoliday.create!(holiday_name: "Saudi National Day", region_code: "sa") }
DisabledHoliday.create!(holiday_name: "New Year's Day", region_code: "sg")
DisabledHoliday.create!(holiday_name: "Chinese New Year", region_code: "sg")
end
let(:holidays) do let(:holidays) do
Holiday.find_holidays_for( Holiday.find_holidays_for(
region_code: "sg", region_code: "sa",
start_date: "2022-01-01", start_date: "2023-02-21",
end_date: "2022-04-30", end_date: "2023-09-23",
) )
end end
it "returns a list of holidays indicating whether a holiday is disabled or not" do it "returns a list of holidays indicating whether a holiday is disabled or not" do
expect(holidays).to include( expect(holidays).to include(
a_hash_including({ name: "New Year's Day", regions: [:sg], disabled: true }), a_hash_including({ name: "Saudi National Day", regions: [:sa], disabled: true }),
) )
expect(holidays).to include( expect(holidays).to include(
a_hash_including({ name: "Chinese New Year", regions: [:sg], disabled: true }), a_hash_including({ name: "Foundation Day", regions: [:sa], disabled: false }),
)
expect(holidays).to include(
a_hash_including({ name: "Good Friday", regions: [:sg], disabled: false }),
) )
end end

View File

@ -2,6 +2,10 @@
--- ---
months: months:
2:
- name: Foundation Day
regions: [sa]
mday: 22
5: 5:
- name: Festival of Breaking the Fast - name: Festival of Breaking the Fast
regions: [sa] regions: [sa]

View File

@ -12,6 +12,7 @@ module Holidays
def self.holidays_by_month def self.holidays_by_month
{ {
2 => [{:mday => 22, :name => "Foundation Day", :regions => [:sa]}],
5 => [{:mday => 2, :year_ranges => { :limited => [2022] },:name => "Festival of Breaking the Fast", :regions => [:sa]}, 5 => [{:mday => 2, :year_ranges => { :limited => [2022] },:name => "Festival of Breaking the Fast", :regions => [:sa]},
{:mday => 3, :year_ranges => { :limited => [2022] },:name => "Second Day of the Festival of Breaking the Fast", :regions => [:sa]}, {:mday => 3, :year_ranges => { :limited => [2022] },:name => "Second Day of the Festival of Breaking the Fast", :regions => [:sa]},
{:mday => 4, :year_ranges => { :limited => [2022] },:name => "Third Day of the Festival of Breaking the Fast", :regions => [:sa]}], {:mday => 4, :year_ranges => { :limited => [2022] },:name => "Third Day of the Festival of Breaking the Fast", :regions => [:sa]}],

View File

@ -12,18 +12,18 @@ module Holidays
def self.holidays_by_month def self.holidays_by_month
{ {
1 => [{:mday => 1, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "New Year's Day", :regions => [:sg]}], 1 => [{:mday => 1, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "New Year's Day", :regions => [:sg]},
2 => [{:mday => 1, :year_ranges => { :limited => [2022] },:name => "Chinese New Year", :regions => [:sg]}, {:mday => 23, :year_ranges => { :limited => [2023] },:name => "First day of Chinese New Year (Observed)", :regions => [:sg]},
{:mday => 2, :year_ranges => { :limited => [2022] },:name => "Chinese New Year Holiday", :regions => [:sg]}, {:mday => 24, :year_ranges => { :limited => [2023] },:name => "Second day of Chinese New Year", :regions => [:sg]}],
{:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:sg]}, 2 => [{:mday => 14, :type => :informal, :name => "Valentine's Day", :regions => [:sg]},
{:mday => 15, :type => :informal, :name => "Total Defence Day", :regions => [:sg]}], {:mday => 15, :type => :informal, :name => "Total Defence Day", :regions => [:sg]}],
4 => [{:mday => 15, :year_ranges => { :limited => [2022] },:name => "Good Friday", :regions => [:sg]}], 4 => [{:mday => 7, :year_ranges => { :limited => [2023] },:name => "Good Friday", :regions => [:sg]},
5 => [{:mday => 1, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "Labour Day", :regions => [:sg]}, {:mday => 24, :year_ranges => { :limited => [2023] },:name => "Hari Raya Puasa (Observed)", :regions => [:sg]}],
{:mday => 3, :year_ranges => { :limited => [2022] },:name => "Hari Raya Puasa", :regions => [:sg]}, 5 => [{:mday => 1, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "Labour Day", :regions => [:sg]}],
{:mday => 16, :year_ranges => { :limited => [2022] },:name => "Vesak Day Holiday", :regions => [:sg]}], 6 => [{:mday => 2, :year_ranges => { :limited => [2023] },:name => "Vesak Day", :regions => [:sg]},
7 => [{:mday => 11, :year_ranges => { :limited => [2022] },:name => "Hari Raya Haji Holiday", :regions => [:sg]}], {:mday => 29, :year_ranges => { :limited => [2023] },:name => "Hari Raya Haji", :regions => [:sg]}],
8 => [{:mday => 9, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "National Day", :regions => [:sg]}], 8 => [{:mday => 9, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "National Day", :regions => [:sg]}],
10 => [{:mday => 24, :year_ranges => { :limited => [2022] },:name => "Deepavali", :regions => [:sg]}], 11 => [{:mday => 13, :year_ranges => { :limited => [2023] },:name => "Deepavali (Observed)", :regions => [:sg]}],
12 => [{:mday => 25, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:sg]}] 12 => [{:mday => 25, :observed => "to_weekday_if_weekend(date)", :observed_arguments => [:date], :name => "Christmas Day", :regions => [:sg]}]
} }
end end