Skip to content

Commit

Permalink
Fix #27 - AU NSW 2016. Boxing Day shifted by weekend
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Willey committed Apr 28, 2018
1 parent 1d87460 commit d9c3346
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
10 changes: 9 additions & 1 deletion src/PublicHoliday/AustraliaPublicHoliday.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,15 @@ public static DateTime Christmas(int year)
/// <returns></returns>
public static DateTime BoxingDay(int year)
{
return HolidayCalculator.FixWeekend(new DateTime(year, 12, 26));
DateTime hol = new DateTime(year, 12, 26);
//if Xmas=Sun, it's shifted to Mon and 26 also gets shifted
bool isSundayOrMonday =
hol.DayOfWeek == DayOfWeek.Sunday ||
hol.DayOfWeek == DayOfWeek.Monday;
hol = HolidayCalculator.FixWeekend(hol);
if (isSundayOrMonday)
hol = hol.AddDays(1);
return hol;
}

#endregion Individual Holidays
Expand Down
4 changes: 2 additions & 2 deletions src/PublicHoliday/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.1.0")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: AssemblyVersion("2.0.2.0")]
[assembly: AssemblyFileVersion("2.0.2.0")]
4 changes: 2 additions & 2 deletions src/PublicHoliday/PublicHoliday.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyName>PublicHoliday</AssemblyName>
<PackageId>PublicHoliday</PackageId>
<PackageTags>Holiday</PackageTags>
<PackageReleaseNotes>2.0.1: Fix for US Thanksgiving (thanks @yschiller)</PackageReleaseNotes>
<PackageReleaseNotes>2.0.2: Fix for AU-NSW-2016 (thanks @dotnetshadow)</PackageReleaseNotes>
<PackageProjectUrl>https://github.com/martinjw/Holiday</PackageProjectUrl>
<PackageLicenseUrl>http://opensource.org/licenses/MIT</PackageLicenseUrl>
<RepositoryType>git</RepositoryType>
Expand All @@ -21,7 +21,7 @@
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GenerateAssemblyFileVersionAttribute>false</GenerateAssemblyFileVersionAttribute>
<Version>2.0.1</Version>
<Version>2.0.2</Version>
</PropertyGroup>
<PropertyGroup>
<FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
Expand Down
11 changes: 11 additions & 0 deletions tests/PublicHolidayTests/TestAustraliaPublicHoliday.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,16 @@ public void TestWesternAustralia2017(int month, int day, string name)
var actual = holidayCalendar.IsPublicHoliday(holiday);
Assert.IsTrue(actual, $"{holiday.ToString("D")} is not a holiday - should be {name}");
}


[TestMethod]
public void TestAustralianNSW2016Lists()
{
var holidayCalendar = new AustraliaPublicHoliday { State = AustraliaPublicHoliday.States.NSW };
var hols = holidayCalendar.PublicHolidays(2016);
var holNames = holidayCalendar.PublicHolidayNames(2016);
Assert.IsTrue(9 == hols.Count, "Should be 9 holidays in 2016");
Assert.IsTrue(holNames.Count == hols.Count, "Names and holiday list are same");
}
}
}

0 comments on commit d9c3346

Please sign in to comment.