Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

United States - Fix Indigenous Peoples' Day #625

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 58 additions & 17 deletions src/Nager.Date/HolidayProviders/UnitedStatesHolidayProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ public IDictionary<string, string> GetSubdivisionCodes()
/// <inheritdoc/>
protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(int year)
{

var thirdMondayInJanuary = DateHelper.FindDay(year, Month.January, DayOfWeek.Monday, Occurrence.Third);
var thirdMondayInFebruary = DateHelper.FindDay(year, Month.February, DayOfWeek.Monday, Occurrence.Third);
var lastMondayInMay = DateHelper.FindLastDay(year, Month.May, DayOfWeek.Monday);
Expand Down Expand Up @@ -179,24 +178,11 @@ protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(in
this._catholicProvider.GoodFriday("Good Friday", year).SetSubdivisionCodes("US-TX").SetHolidayTypes(HolidayTypes.Optional)
};

if (year >= 2021)
{
holidaySpecifications.AddIfNotNull(new HolidaySpecification
{
Date = new DateTime(year, 6, 19),
EnglishName = "Juneteenth",
LocalName = "Juneteenth",
HolidayTypes = HolidayTypes.Public,
ObservedRuleSet = observedRuleSet
});

//var juneteenth = new DateTime(year, 6, 19).Shift(saturday => saturday.AddDays(-1), sunday => sunday.AddDays(1));
//items.Add(new Holiday(juneteenth, "Juneteenth", "Juneteenth", countryCode, 2021));
}
holidaySpecifications.AddIfNotNull(this.JuneteenthNationalIndependenceDay(year, observedRuleSet));
holidaySpecifications.AddIfNotNull(this.IndigenousPeoplesDay(year));

return holidaySpecifications;


//var items = new List<Holiday>();

//#region New Years Day with fallback
Expand Down Expand Up @@ -250,13 +236,68 @@ protected override IEnumerable<HolidaySpecification> GetHolidaySpecifications(in
//return items.OrderBy(o => o.Date);
}

private HolidaySpecification JuneteenthNationalIndependenceDay(
int year,
ObservedRuleSet observedRuleSet)
{
if (year >= 2021)
{
return new HolidaySpecification
{
Date = new DateTime(year, 6, 19),
EnglishName = "Juneteenth National Independence Day",
LocalName = "Juneteenth National Independence Day",
HolidayTypes = HolidayTypes.Public,
ObservedRuleSet = observedRuleSet
};
}

return null;
}

private HolidaySpecification IndigenousPeoplesDay(int year)
{
if (year < 1988)
{
return null;
}

var secondMondayInOctober = DateHelper.FindDay(year, Month.October, DayOfWeek.Monday, Occurrence.Second);

var indigenousPeoplesDay = new HolidaySpecification
{
Date = secondMondayInOctober,
EnglishName = "Indigenous Peoples' Day",
LocalName = "Indigenous Peoples' Day",
HolidayTypes = HolidayTypes.Public
};

string[] subdivisionCodes = year switch
{
1988 => ["US-HI"],
>= 1989 and < 2015 => ["US-HI", "US-SD"],
2015 => ["US-AK", "US-HI", "US-SD"],
>= 2016 and < 2018 => ["US-AK", "US-HI", "US-MN", "US-SD", "US-VT"],
2018 => ["US-AK", "US-HI", "US-IA", "US-MN", "US-NC", "US-SD", "US-VT"],
2019 => ["US-AK", "US-AL", "US-CA", "US-HI", "US-IA", "US-LA", "US-ME", "US-MI", "US-MN", "US-NC", "US-NM", "US-OK", "US-SD", "US-VT", "US-WI"],
2020 => ["US-AK", "US-AL", "US-CA", "US-HI", "US-IA", "US-LA", "US-ME", "US-MI", "US-MN", "US-NC", "US-NE", "US-NM", "US-OK", "US-SD", "US-VA", "US-VT", "US-WI"],
>= 2021 => ["US-AK", "US-AL", "US-CA", "US-HI", "US-IA", "US-LA", "US-ME", "US-MI", "US-MN", "US-NC", "US-NE", "US-NM", "US-OK", "US-OR", "US-SD", "US-TX", "US-VA", "US-VT", "US-WI"],
_ => [],
};

indigenousPeoplesDay.SubdivisionCodes = subdivisionCodes;
return indigenousPeoplesDay;

}

/// <inheritdoc/>
public override IEnumerable<string> GetSources()
{
return
[
"https://en.wikipedia.org/wiki/Federal_holidays_in_the_United_States",
"https://www.whitehouse.gov/briefing-room/speeches-remarks/2021/06/17/remarks-by-president-biden-at-signing-of-the-juneteenth-national-independence-day-act/"
"https://www.whitehouse.gov/briefing-room/speeches-remarks/2021/06/17/remarks-by-president-biden-at-signing-of-the-juneteenth-national-independence-day-act/",
"https://en.wikipedia.org/wiki/Indigenous_Peoples%27_Day_(United_States)#Indigenous_Peoples_Day_observers"
];
}
}
Expand Down