Nager.Date
Nager.Date copied to clipboard
Bug fix for RomaniaProvider ignoring the LaunchYear property of the PublicHoliday
This PR implements the missing launch year filter for Romania which caused incorrect results and also adds unit tests for multiple years.
Currently no provider filter by launch year. It is an optional value.
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.
I think at the moment you can also filter the LaunchYear
after the request. I will consider your proposal.
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.