azuyalabs / yasumi

The easy PHP Library for calculating holidays
https://www.yasumi.dev
Other
1.04k stars 152 forks source link

Provider for Canada #59

Closed AronNovak closed 4 years ago

AronNovak commented 7 years ago

Reference: https://en.wikipedia.org/wiki/Public_holidays_in_Canada

cruxicheiros commented 5 years ago

Hi, I'm interested in working on this provider. I'm wondering how localisation should be approached, though, given that Canada has two official languages. Are there any already implemented providers that have this already?

Found one (Belgium). Sorry!

stelgenhof commented 5 years ago

Hi @cruxicheiros!

Thanks for wanting to contributing to this project!

Localization is pretty easy. For every holiday a translation is defined in a translation file. (See: https://github.com/azuyalabs/yasumi/tree/develop/src/Yasumi/data/translations). So you can just provide a translation for Canadian English and Canadian French in such a file.

If the holiday is already a known one (e.g. Christmas), then the translation can be added to the existing translation file. Conversely, if there is a typical Canadian Holiday that would only need translation for Canadian English and Canadian French, then these can be embedded in the Holiday Provider file for Canada.

Hope it makes sense a bit ;) Just have a look at the source code; it is quite straight forward.

Cheers! Sacha

stelgenhof commented 5 years ago

@cruxicheiros Good to hear you found it. Just wondering: does it mean you are going to work on the Canada Holiday Provider or only provide translations for the existing holidays?

cruxicheiros commented 5 years ago

I mean that I will work on the actual provider. I'm going to source the translations from government sources.

On Wed, 14 Nov 2018, 06:00 Sacha Telgenhof <notifications@github.com wrote:

@cruxicheiros https://github.com/cruxicheiros Good to hear you found it. Just wondering: does it mean you are going to work on the Canada Holiday Provider or only provide translations for the existing holidays?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/azuyalabs/yasumi/issues/59#issuecomment-438547993, or mute the thread https://github.com/notifications/unsubscribe-auth/ARqLTGxsu8gAgiTej1JmC4p3RhsKVAjEks5uu7GEgaJpZM4MYG1U .

stelgenhof commented 5 years ago

Cool! If you're stuck or not sure how to code something, just let me know.

cruxicheiros commented 5 years ago

Hi, I've started working on this and I was wondering what the preferred way to deal with this situation is.

In Quebec, non-federally regulated employers must give either Good Friday or Easter Monday as a statutory holiday, though some give both days. (source wikipedia)

I think that this means that they should both be Holiday::TYPE_OFFICIAL across Canada but I'm unsure.

stelgenhof commented 5 years ago

@cruxicheiros Good question as it is a situation that also happens in other countries.

The best way to look at it is, to separate non-working days from national holidays. Commonly (but not always), national/official holidays mean a non-working day.

I would indeed classify both holidays as 'official': whether some employers provide either/or as a statutory holiday is more of a business domain matter.

Hope this helps! Sacha

cruxicheiros commented 5 years ago

This has been really interesting to work on so far, and I'm glad that my Canadian social studies education is (finally) coming to some use!

I've run into a few further difficulties, though, mostly to do with historical accuracy and how important it is to the provider.

So, Canada is not a very old country. In fact, it was confederated in 1867. This means that there is not a lot of history, so not a lot of weird stuff and exceptions, right?

Right?

Right?

...okay, maybe not. I'll try to give a short version of the history that gives some context to the problems I'm having.

Canada being confederated in 1867 just meant that the colonies of Canada, New Brunswick, and Nova Scotia were united into the Dominion of Canada. Canada at this time was still a dominion of Britain, and wouldn't gain legal freedom from Britain until 1931, when the Statute of Westminster was passed. It also didn't contain a significant amount of the territory that is now part of Canada. You can find a list of dates that different provinces/territories became part of Canada here.

For most intents and purposes, the federal government of Canada likes to act like Canada started in 1867, but quite often things that happened earlier are referenced. For example, Thanksgiving was observed in Canada (and what would become Canada) for a long time before it was first declared by proclamation in 1879, but it wouldn't be given a fixed date until 1957. At that time, not all of the provinces that are currently in Canada were part of it, so trying to provide historically accurate holiday data for individual provinces is very difficult.

Victoria Day (wikipedia) is also a source of grief. Why? Well, just have a look at its history (which happens to start before Confederation). It gets worse, though: Victoria Day wasn't officially Victoria Day until Queen Victoria died. Before that, it was just the sovereign's birthday. Then, it was statically placed on May 24 (and substituted May 25 if that was a Sunday), and for a while the regent's birthday was kept on the same day. But then the sovereign's birthday date moved around to the current sovereign's birthday while Victoria Day remained the same. And then the UK came up with their date for the regent's birthday, which Canada first matched by proclamation but then switched to their own date. Finally, in 1953, Canada fixed Victoria Day to a different date and declared that the Queen's birthday was on Victoria Day instead of the other way around.

Also, Empire Day (later Commonwealth Day) for a while coincided with Victoria Day.

There are two options going forward, but I think that only one of them is feasible. The first, the one I don't like, is to treat Canada as a monolith and ignore the provinces and provincial holidays entirely. I don't like this because it would make the Canada provider pretty much useless for most purposes as provinces tend to declare a lot of holidays and observances. It also would give the impression of historical accuracy but would in fact be inaccurate since Canada was not ever one united country doing one thing since Confederation.

The second option, which I greatly prefer, is scrapping historical dates of events and only considering current holidays. However, this isn't the pattern set by some other providers I've looked at, so I'd like input on this. Maybe there are other approaches I haven't considered?

Thanks, Clark

stelgenhof commented 5 years ago

Thanks for the nice background information! What is for Canada, is the case for many other countries as well.

Being a perfectionist, I'd like this library to capture holidays accurately, however do realize that it isn't always possible or feasible. My approach when adding providers for this library is based on practicality and implementation effort.

I would first focus on the holidays that are well known, well documented and useful for the majority of this library's users. Putting a lot of effort in capturing historically accurate holidays that may not be of any use to the public, is something to be avoided. Only when there is a real need...

That being said, I would also go for the second option: recording the holidays by provinces (similar to other countries in this library).

Cheers! Sacha

cruxicheiros commented 5 years ago

Hi, I have been doing some work on this. What is the preferred way to deal with holidays that are nationally observed but have different statuses in different provinces (i.e. an official holiday in some provinces but an observance in others?)

stelgenhof commented 5 years ago

@cruxicheiros Sorry for the late reply. You can easily create default holidays nationally and then override the logic of these in the different provinces. Have a look at the Australian Holiday Provider as that is one of the most complex ones...

You can either use traits or put the common holidays in the main (Canada) class.

cruxicheiros commented 5 years ago

No problem, thanks for letting me know.

On Tue, 8 Jan 2019, 11:36 Sacha Telgenhof <notifications@github.com wrote:

@cruxicheiros https://github.com/cruxicheiros Sorry for the late reply. You can easily create default holidays nationally and then override the logic of these in the different provinces. Have a look at the Australian Holiday Provider as that is one of the most complex ones...

You can either use traits or put the common holidays in the main (Canada) class.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/azuyalabs/yasumi/issues/59#issuecomment-452268218, or mute the thread https://github.com/notifications/unsubscribe-auth/ARqLTE04caHox9vTFVsoXwmveFJzqqqEks5vBIKogaJpZM4MYG1U .

stelgenhof commented 5 years ago

@cruxicheiros Do you have an estimate when you like to submit your PR? I am preparing a next release and would be nice to include Canada as well.

Cheers! Sacha

cruxicheiros commented 5 years ago

So far I have only been working on it when I felt like it, but it would be neat to have it in a release so I will see if I can have something workable by the beginning of February. The bit which is giving me pause is writing unit tests for all the provinces.

On Tue, 8 Jan 2019, 11:41 Sacha Telgenhof <notifications@github.com wrote:

@cruxicheiros https://github.com/cruxicheiros Do you have an estimate when you like to submit your PR? I am preparing a next release and would be nice to include Canada as well.

Cheers! Sacha

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/azuyalabs/yasumi/issues/59#issuecomment-452269607, or mute the thread https://github.com/notifications/unsubscribe-auth/ARqLTNT8mEuOvk7oFpRR_AX6JymqnYGvks5vBIPzgaJpZM4MYG1U .

stelgenhof commented 5 years ago

I was actually planning to do a release this week (at the latest next week). Let me then help you with your work. Do you have a fork/repos I can access? I can then see how much work you still have to do and if it would be feasible to include in the next release.

Cheers! Sacha

cruxicheiros commented 5 years ago

I do have a fork, I believe it is at cruxicheiros/yasumi. However I don't have nearly enough done to have it done for the next release. Can we make next next release a target?

On Tue, 8 Jan 2019, 12:02 Sacha Telgenhof <notifications@github.com wrote:

I was actually planning to do a release this week (at the latest next week). Let me then help you with your work. Do you have a fork/repos I can access? I can then see how much work you still have to do and if it would be feasible to include in the next release.

Cheers! Sacha

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/azuyalabs/yasumi/issues/59#issuecomment-452274802, or mute the thread https://github.com/notifications/unsubscribe-auth/ARqLTOkEN7quTh8aPceXz8LaNsY9L48Yks5vBIjngaJpZM4MYG1U .

stelgenhof commented 5 years ago

Ok. No rush! :) Canada can join another release :) Anyway, if you need any help with your work/fork, let me know.

nick2687 commented 5 years ago

How is this coming along? I would love to contribute to get this across the line in the next release if help is needed.

github-actions[bot] commented 4 years ago

This issue has been open 60 days with no activity. Please remove the stale label or comment, or this will be closed in 10 days.