Skip to content

Commit b857a1d

Browse files
committed
#135 Bavarian Holidays Assumption is conditional
1 parent ab9c1de commit b857a1d

File tree

5 files changed

+36
-7
lines changed

5 files changed

+36
-7
lines changed

src/PublicHoliday/GermanPublicHoliday.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,13 +259,23 @@ public static DateTime Assumption(int year)
259259
return new DateTime(year, 8, 15);
260260
}
261261

262+
private bool? _hasAssumption;
262263
/// <summary>
263264
/// Whether this state observes Mariä Himmelfahrt.
264265
/// </summary>
265266
/// <value>
266267
/// <c>true</c> if this state observes Mariä Himmelfahrt; otherwise, <c>false</c>.
267268
/// </value>
268-
public bool HasAssumption => States.SL == State || States.BY == State;
269+
public bool HasAssumption
270+
{
271+
get
272+
{
273+
//if they set manually, override the state default
274+
if(_hasAssumption.HasValue) return _hasAssumption.Value;
275+
return States.SL == State || States.BY == State;
276+
}
277+
set => _hasAssumption = value;
278+
}
269279

270280
/// <summary>
271281
/// Kindertag - World Children's Day

src/PublicHoliday/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("2.39.0.0")]
36-
[assembly: AssemblyFileVersion("2.39.0.0")]
35+
[assembly: AssemblyVersion("2.40.0.0")]
36+
[assembly: AssemblyFileVersion("2.40.0.0")]
3737

3838
// Visibility of project of test
3939
[assembly: InternalsVisibleTo("PublicHolidayTests")]

src/PublicHoliday/PublicHoliday.csproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
2.36.0: #116 Fixed Japanese Vernal and Autumnal Equinox days (thanks @Makaopior )
5555
2.37.0: #120 Add Brazil holidays (thanks @rsegecin ), Netherlands add Good Friday (thanks @wdnijdam )
5656
2.38.0: #122 Update Switzerland Holiday with Cantons (thanks @tossnet), Add NYSE holidays (thanks @stephenherrick )
57-
2.39.0: #125 Fix Turkey Ramadan and FeastOfSacrifices holidays (thanks @hasankaplan-github), #128 Update Switzerland Holiday (thanks @tossnet),; #131 Update France holiday with overseas territories (thanks @tossnet); #132 Add Portugal Holiday (thanks @greybird); #133 South Africa 2024 election day (thanks @FifoTheHein)</PackageReleaseNotes>
57+
2.39.0: #125 Fix Turkey Ramadan and FeastOfSacrifices holidays (thanks @hasankaplan-github), #128 Update Switzerland Holiday (thanks @tossnet),; #131 Update France holiday with overseas territories (thanks @tossnet); #132 Add Portugal Holiday (thanks @greybird); #133 South Africa 2024 election day (thanks @FifoTheHein)
58+
2.40.0: #135 Bavarian Assumption date is conditional</PackageReleaseNotes>
5859
<PackageProjectUrl>https://github.com/martinjw/Holiday</PackageProjectUrl>
5960
<PackageLicenseUrl></PackageLicenseUrl>
6061
<Description>Calculate national public holidays for countries including US, UK, France, Belgium, Germany, Australia, Canada and many others for any year</Description>
@@ -69,7 +70,7 @@
6970
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
7071
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
7172
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
72-
<Version>2.39.0</Version>
73+
<Version>2.40.0</Version>
7374

7475
<PackageLicenseExpression>MIT</PackageLicenseExpression>
7576
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>

tests/PublicHolidayTests/PublicHolidayTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121

2222
<ItemGroup>
2323
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
24-
<PackageReference Include="MSTest.TestAdapter" Version="3.4.3" />
25-
<PackageReference Include="MSTest.TestFramework" Version="3.4.3" />
24+
<PackageReference Include="MSTest.TestAdapter" Version="3.5.1" />
25+
<PackageReference Include="MSTest.TestFramework" Version="3.5.1" />
2626
</ItemGroup>
2727

2828
<ItemGroup>

tests/PublicHolidayTests/TestGermanyPublicHoliday.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,23 @@ public void TestBrandenbugSundayHolidays()
157157
// Pentecost sunday
158158
Assert.IsTrue(calendar.PublicHolidays(2023).Contains(new DateTime(2023, 5, 28)));
159159
}
160+
161+
[TestMethod]
162+
public void TestBavariaAssumption()
163+
{
164+
var assumption = GermanPublicHoliday.Assumption(2024);
165+
//assumption is 15/08/2024
166+
var calendar = new GermanPublicHoliday { State = GermanPublicHoliday.States.BY };
167+
var isHoliday = calendar.IsPublicHoliday(assumption); //true
168+
Assert.IsTrue(isHoliday);
169+
170+
var hasAssumption = calendar.HasAssumption; //true
171+
Assert.IsTrue(hasAssumption);
172+
//override the default - it should be false
173+
calendar.HasAssumption = false;
174+
isHoliday = calendar.IsPublicHoliday(assumption); //false
175+
Assert.IsFalse(isHoliday);
176+
177+
}
160178
}
161179
}

0 commit comments

Comments
 (0)