Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AustriaPublicHoliday.IsPublicHoliday #12

Closed
oliver-h opened this issue May 24, 2017 · 1 comment
Closed

AustriaPublicHoliday.IsPublicHoliday #12

oliver-h opened this issue May 24, 2017 · 1 comment

Comments

@oliver-h
Copy link

Hello there,

I was about to use your nice and useful lib and did some validation prior to that. I found a little bug:

The following code snippet will print the dates 30.5.2013 and 26.5.2016 (Corpus Christi), which should not happen:

var h = new AustriaPublicHoliday();

for (int year = 2010; year < 2018; year++)
{
    var days = h.PublicHolidays(year);
    var fd = days.Where(d => !h.IsPublicHoliday(d));

    if (fd.Any())
        Console.WriteLine(string.Join(Environment.NewLine, fd));
}

Wouldn't it be easier to use the PublicHolidays list to check against a single date in the IsPublicHolday method?

Best regards,
Oliver

@martinjw
Copy link
Owner

The reason IsPublicHoliday doesn't use the list is for performance. If you hit that method a lot, and it creates the full list for the year each time, it starts rising up the profiler hot spots list. Obviously it's even more efficient to grab the list from PublicHolidays and directly check against that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants