Skip to content

Commit bcecba2

Browse files
Merge pull request #271 from bail16/feature/pl-christmas-eve-holiday
PL: Add Christmas Eve (24 Dec) as public holiday from 2025, update holiday logic and tests (AddWorkingDays, holiday detection)
2 parents a186577 + ddb8f82 commit bcecba2

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/DateTimeExtensions/WorkingDays/CultureStrategies/PL_PLHolidayStrategy.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public PL_PLHolidayStrategy()
2626

2727
this.InnerHolidays.Add(ChristianHolidays.Christmas);
2828
this.InnerHolidays.Add(ChristianHolidays.StStephansDay);
29+
this.InnerHolidays.Add(ChristmasEveFrom2025);
2930
}
3031

3132
private static Holiday may3rdConstitutionDay;
@@ -55,5 +56,18 @@ public static Holiday NationalIndependenceDay
5556
return nationalIndependenceDay;
5657
}
5758
}
59+
60+
private static Holiday christmasEveFrom2025;
61+
public static Holiday ChristmasEveFrom2025
62+
{
63+
get
64+
{
65+
if (christmasEveFrom2025 == null)
66+
{
67+
christmasEveFrom2025 = new YearDependantHoliday(year => year >= 2025, new FixedHoliday("Christmas Eve", 12, 24));
68+
}
69+
return christmasEveFrom2025;
70+
}
71+
}
5872
}
5973
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using NUnit.Framework;
3+
using DateTimeExtensions.WorkingDays;
4+
using DateTimeExtensions.WorkingDays.CultureStrategies;
5+
6+
namespace DateTimeExtensions.Tests
7+
{
8+
[TestFixture]
9+
public class PLHolidaysTests
10+
{
11+
private WorkingDayCultureInfo dateTimeCulture = new WorkingDayCultureInfo("pl-PL");
12+
13+
[Test]
14+
[TestCase(2024, false)]
15+
[TestCase(2025, true)]
16+
[TestCase(2026, true)]
17+
public void ChristmasEve_Is_Holiday_From_2025(int year, bool shouldBeHoliday)
18+
{
19+
var date = new DateTime(year, 12, 24);
20+
Assert.That(dateTimeCulture.IsHoliday(date), Is.EqualTo(shouldBeHoliday), $"Christmas Eve {year} should be a holiday: {shouldBeHoliday}");
21+
}
22+
23+
[Test]
24+
public void AddWorkingDays_Skips_ChristmasEve_From_2025()
25+
{
26+
// 23.12.2025 (Tuesday) + 1 working day = 29.12.2025 (Monday); 24-26.12 are holidays
27+
var start = new DateTime(2025, 12, 23);
28+
var result = start.AddWorkingDays(1, dateTimeCulture);
29+
Assert.That(result, Is.EqualTo(new DateTime(2025, 12, 29)));
30+
}
31+
32+
[Test]
33+
public void AddWorkingDays_DoesNotSkip_ChristmasEve_Before_2025()
34+
{
35+
// 23.12.2024 (Monday) + 1 working day = 24.12.2024 (Tuesday); Christmas Eve is not a holiday
36+
var start = new DateTime(2024, 12, 23);
37+
var result = start.AddWorkingDays(1, dateTimeCulture);
38+
Assert.That(result, Is.EqualTo(new DateTime(2024, 12, 24)));
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)