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

Get IPublicHoliday by culture code #48

Closed
gabriele-ricci-kyklos opened this issue Dec 17, 2020 · 2 comments
Closed

Get IPublicHoliday by culture code #48

gabriele-ricci-kyklos opened this issue Dec 17, 2020 · 2 comments

Comments

@gabriele-ricci-kyklos
Copy link

Is there any way to retrieve an IPublicHoliday based on a culture code like en-US?

@martinjw
Copy link
Owner

It would be easy to write a simple factory method that did this.

        public IPublicHolidays Factory(CultureInfo culture)
        {
            switch (culture.Name)
            {
                case "en-US":
                    return new USAPublicHoliday();
                case "en-CA":
                    return new CanadaPublicHoliday();
                case "en-GB":
                    return new UKBankHoliday();
                default:
                    throw new InvalidOperationException("Culture not known or specified");
            }
        }

It becomes a bit more complex if you're dealing with regions (as in Canada), multi-language countries (Canada again), and regions that don't have an ISO culture code (Scotland, which has Scottish Gaelic gd-GB but not en-scot).

Also this library isn't really localized- hol.PublicHolidayNames() returns local names in the majority local language, but not language and regional variations (one exception is Belgium, where I did Flemish and French methods- and I still skipped German). To do this properly (and perhaps add language neutral variants) would be a major effort.

@gabriele-ricci-kyklos
Copy link
Author

All right, I thought that there might be something already built-in into the lib but I'll do something as you described

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