Nager.Date icon indicating copy to clipboard operation
Nager.Date copied to clipboard

Bug fix for RomaniaProvider ignoring the LaunchYear property of the PublicHoliday

Open BalintBanyasz opened this issue 5 years ago • 4 comments

This PR implements the missing launch year filter for Romania which caused incorrect results and also adds unit tests for multiple years.

BalintBanyasz avatar Jan 05 '20 17:01 BalintBanyasz

Currently no provider filter by launch year. It is an optional value.

tinohager avatar Jan 06 '20 12:01 tinohager

Currently no provider filter by launch year. It is an optional value.

In that case, this is a more general issue.

I would expect that all functions that return holidays for a given date, year or date range, should always respect the launch year of the holidays, otherwise, the returned holidays may not be valid (like in case of Romania, Good Friday and Children's Day are incorrectly returned for years earlier than 2018 and 2017 respectively). Putting this filter right in the Get(int year) method seemed like right place to prevent any errors, even if accessed directly.

I understand that the LaunchYear is an optional parameter, but the condition .Where(x => x.LaunchYear == null || x.LaunchYear <= year) already respects this because it returns all holidays that don't have a launch year defined.

BalintBanyasz avatar Jan 06 '20 19:01 BalintBanyasz

I think at the moment you can also filter the LaunchYear after the request. I will consider your proposal.

tinohager avatar Jan 06 '20 19:01 tinohager

Sure, I understand that. The problem is that one would expect that getting the holidays for a specific year would use the rule set that was in effect for the given year. I can't think of a scenario where one would need the holidays that are in effect today to be projected to a past year where they did't exist.

BalintBanyasz avatar Jan 06 '20 20:01 BalintBanyasz