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

Update to Ukrainian holidays in UkraineHolidayProvider.cs #676

Merged
merged 3 commits into from
Sep 17, 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
120 changes: 91 additions & 29 deletions src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
HolidayTypes = HolidayTypes.Public
},
new HolidaySpecification
{
Date = new DateTime(year, 1, 7),
EnglishName = "(Julian) Christmas",
LocalName = "Різдво",
HolidayTypes = HolidayTypes.Public
},
new HolidaySpecification
{
Date = new DateTime(year, 3, 8),
EnglishName = "International Women's Day",
Expand All @@ -57,13 +50,6 @@
HolidayTypes = HolidayTypes.Public
},
new HolidaySpecification
{
Date = new DateTime(year, 5, 9),
EnglishName = "Victory day over Nazism in World War II",
LocalName = "День перемоги над нацизмом у Другій світовій війні",
HolidayTypes = HolidayTypes.Public
},
new HolidaySpecification
{
Date = new DateTime(year, 6, 28),
EnglishName = "Constitution Day",
Expand All @@ -77,33 +63,64 @@
LocalName = "День Незалежності",
HolidayTypes = HolidayTypes.Public
},
new HolidaySpecification
{
Date = new DateTime(year, 10, 14),
EnglishName = "Defender of Ukraine Day",
LocalName = "День захисника України",
HolidayTypes = HolidayTypes.Public
},
new HolidaySpecification
{
Date = new DateTime(year, 12, 25),
EnglishName = "(Gregorian and Revised Julian) Christmas",
LocalName = "Різдво",
HolidayTypes = HolidayTypes.Public
},
this._orthodoxProvider.EasterSunday("Великдень", year),
this._orthodoxProvider.Pentecost("Трійця", year)
};

holidaySpecifications.AddIfNotNull(this.JulianChristmasDay(year));
holidaySpecifications.AddIfNotNull(this.StatehoodDay(year));
holidaySpecifications.AddIfNotNull(this.DefenderDay(year));
holidaySpecifications.AddIfNotNull(this.GregorianChristmasDay(year));
holidaySpecifications.AddIfNotNull(this.VictoryDay(year));

return holidaySpecifications;
}

private HolidaySpecification VictoryDay(int year)
{
var englishName = "Victory day over Nazism in World War II";
var localName = "День перемоги над нацизмом у Другій світовій війні";

if (year < 2024)
{
return new HolidaySpecification
{
Date = new DateTime(year, 5, 9),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Public
};
}

return new HolidaySpecification
{
Date = new DateTime(year, 5, 8),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Public
};
}

private HolidaySpecification? JulianChristmasDay(int year)

Check warning on line 104 in src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 104 in src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (year < 2024)
{
return new HolidaySpecification
{
Date = new DateTime(year, 1, 7),
EnglishName = "(Julian) Christmas",
LocalName = "Різдво",
HolidayTypes = HolidayTypes.Public
};
}

return null;
}

private HolidaySpecification? StatehoodDay(int year)

Check warning on line 120 in src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 120 in src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
var englishName = "Statehood Day";
var localName = "Statehood Day";
var localName = "День Української Державності";

if (year == 2022 || year == 2023)
{
Expand All @@ -129,6 +146,51 @@
return null;
}

private HolidaySpecification? DefenderDay(int year)

Check warning on line 149 in src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 149 in src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
var englishName = "Defender of Ukraine Day";
var localName = "День захисників і захисниць України";

if (year >= 2015 && year < 2023)
{
return new HolidaySpecification
{
Date = new DateTime(year, 10, 14),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Public
};
}
else if (year >= 2023)
{
return new HolidaySpecification
{
Date = new DateTime(year, 10, 1),
EnglishName = englishName,
LocalName = localName,
HolidayTypes = HolidayTypes.Public
};
}

return null;
}

private HolidaySpecification? GregorianChristmasDay(int year)

Check warning on line 178 in src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.

Check warning on line 178 in src/Nager.Date/HolidayProviders/UkraineHolidayProvider.cs

View workflow job for this annotation

GitHub Actions / build

The annotation for nullable reference types should only be used in code within a '#nullable' annotations context.
{
if (year >= 2017)
{
return new HolidaySpecification
{
Date = new DateTime(year, 12, 25),
EnglishName = "(Gregorian and Revised Julian) Christmas",
LocalName = "Різдво",
HolidayTypes = HolidayTypes.Public
};
}

return null;
}

/// <inheritdoc/>
public override IEnumerable<string> GetSources()
{
Expand Down
Loading