Skip to content

Commit

Permalink
Serbia - Fix Weekendshift non-religious holidays
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Oct 10, 2023
1 parent 8cf99ed commit a9054db
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Japan - Fix Health and Sports Day
- Australia - Fix King's Birthday Queensland
- Australia - Fix New Year's Day weekend shift
- Serbia - Fix Weekendshift non-religious holidays

## [1.45.0] - 2023-08-27

Expand Down
23 changes: 17 additions & 6 deletions src/Nager.Date/PublicHolidays/SerbiaProvider.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Nager.Date.Contract;
using Nager.Date.Extensions;
using Nager.Date.Model;
using System;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -26,17 +28,26 @@ public IEnumerable<PublicHoliday> GetHolidays(int year)
{
var countryCode = CountryCode.RS;

var newYearsDay1 = new DateTime(year, 1, 1).Shift(saturday => saturday, sunday => sunday.AddDays(1));
var newYearsDay2 = new DateTime(year, 1, 2).Shift(saturday => saturday, sunday => sunday.AddDays(1), monday => monday.AddDays(1));

var statehoodDay1 = new DateTime(year, 2, 15).Shift(saturday => saturday, sunday => sunday.AddDays(1));
var statehoodDay2 = new DateTime(year, 2, 16).Shift(saturday => saturday, sunday => sunday.AddDays(1), monday => monday.AddDays(1));

var labourDay1 = new DateTime(year, 5, 1).Shift(saturday => saturday, sunday => sunday.AddDays(1));
var labourDay2 = new DateTime(year, 5, 2).Shift(saturday => saturday, sunday => sunday.AddDays(1), monday => monday.AddDays(1));

var items = new List<PublicHoliday>();
items.Add(new PublicHoliday(year, 1, 1, "Nova Godina", "New Year's Day", countryCode));
items.Add(new PublicHoliday(year, 1, 2, "Nova Godina", "New Year's Day", countryCode));
items.Add(new PublicHoliday(newYearsDay1, "Nova Godina", "New Year's Day", countryCode));
items.Add(new PublicHoliday(newYearsDay2, "Nova Godina", "New Year's Day", countryCode));
items.Add(new PublicHoliday(year, 1, 7, "Božić", "Christmas Day", countryCode));
items.Add(new PublicHoliday(year, 2, 15, "Dan državnosti Srbije", "Statehood Day", countryCode));
items.Add(new PublicHoliday(year, 2, 16, "Dan državnosti Srbije", "Statehood Day", countryCode));
items.Add(new PublicHoliday(statehoodDay1, "Dan državnosti Srbije", "Statehood Day", countryCode));
items.Add(new PublicHoliday(statehoodDay2, "Dan državnosti Srbije", "Statehood Day", countryCode));
items.Add(this._orthodoxProvider.GoodFriday("Veliki petak", year, countryCode));
items.Add(this._orthodoxProvider.EasterSunday("Vaskrs (Uskrs)", year, countryCode));
items.Add(this._orthodoxProvider.EasterMonday("Vaskrsni (Uskrsni) ponedeljak", year, countryCode));
items.Add(new PublicHoliday(year, 5, 1, "Praznik rada", "May Day / International Workers' Day", countryCode));
items.Add(new PublicHoliday(year, 5, 2, "Praznik rada", "May Day / International Workers' Day", countryCode));
items.Add(new PublicHoliday(labourDay1, "Praznik rada", "Labour Day", countryCode));
items.Add(new PublicHoliday(labourDay2, "Praznik rada", "Labour Day", countryCode));
items.Add(new PublicHoliday(year, 11, 11, "Dan primirja", "Armistice Day", countryCode));

return items.OrderBy(o => o.Date);
Expand Down

0 comments on commit a9054db

Please sign in to comment.