Comments (4)
Here's what to do:
Create a file fr-CA.py
in holidata/holidays
, enter the new locale fr-CA
in the list of locales in the __init__.py
in the same directory.
Within fr-CA.py
create a class and the following skeleton:
# coding=utf-8
from dateutil.easter import EASTER_WESTERN
from .holidays import Locale
class fr_CA(Locale):
"""
"""
locale = "fr-CA"
easter_type = EASTER_WESTERN
Now gather a list of all public holidays, i.e. days "which are defined by law on which business or work are suspended or reduced". If possible, try to provide the legal sources which define the holidays.
For each holiday:
- Is it a fixed or variable date?
- What is the official name?
- Is it a regional or nation-wide holiday?
- If regional, what are the regions the holiday is observed in? (Note: currently only regions defined in ISO_3166-2 are supported)
For each holiday with a fixed date add a line in the following format within the class doc (between the triple-quotes):
- for regional holidays
MM-DD: [<regions>] [<flags>] <name>
- for nation-wide holidays:
MM-DD: [<flags>] <name>
The relevant flags here are F
for fixed date and N
for national (all regions) and R
for religious (e.g. christmas, church holidays)
For each holiday holiday with a variable date:
- If it depends on the easter date, add a line in the following format within the class doc:
n days (before|after) Easter: [<regions>] [<flags>] <name>
(for Easter,Easter: ...
suffices) - If the holiday is held on a specific weekday, add a line in the following format:
nth. (last)? <weekday> in <month>: [<regions>] [<flags>] <name>
e.g.1. monday in august
or2. last saturday in may
As for fixed holildays the [<regions>]
has to be omitted if it is a nation-wide holiday.
If a holiday has a variable date that cannot be covered by the patterns above, add a function holiday_<holiday_name_in_snake_case>
to the class. The function must return a List[Holiday]
. See the other locales for examples. Such a function is required if
- a holiday is proclaimed by the government
- a holiday is moved to a different date, if they fall on a saturday/sunday/...?
- a holiday is observed on a different date or there is a substitute holiday when they fall on a saturday/sunday/...
- a holiday has been renamed/deleted/created since/after 2011
That's the roadmap more or less. Feel free to ask, if something is still unclear, or just open a PR and we can work out the individual issues there. ;)
from holidata.
Thanks for your quick answer. I had already started on it, using en-US as a template. Going not too bad. I couldn't find how to proceed with the weird-ish holidays (last monday before the 25th of May, "Monday if falls on a Sunday", etc.) and your pointers will help. Hoping to get somewhere.
:-)
from holidata.
OK, now that I've looked into it, the task at hand might be bigger than I thought, so I have a few questions which are probably impacted by your policy/philosophy. I want to respect that, so I prefer to ask. And I would understand perfectly if you'd rather I don't do something. As I said, I really don't want to do something you'd rather not have in your program.
First, there are 13 official regions (provinces and territories) in Canada. Selfishly, I was planning on supporting only the one for Quebec, because I know of the specific provincial government mandated holidays. I do not know for the other regions, so I was planning on leaving them out. This means I would cover only national (i.e. whole Canada) holidays and those specific to Quebec. Would that be alright ?
Second, I would have liked to do the observed dates as you suggested for the holidays, but in Canada (and Quebec), the choice is left to the employer whether the holiday is observed on the Friday or the Monday if the holiday falls on the weekend. This means it isn't actually the same date for everyone. Would you prefer I simply choose the most probable one (usually the closest one), write both or not handle the observed dates ?
Other than those considerations, I think (probably wrongly, but here's to optimism) I could be ready to create a PR this weekend.
Thanks.
from holidata.
First, there are 13 official regions (provinces and territories) in Canada. Selfishly, I was planning on supporting only the one for Quebec, because I know of the specific provincial government mandated holidays. I do not know for the other regions, so I was planning on leaving them out. This means I would cover only national (i.e. whole Canada) holidays and those specific to Quebec. Would that be alright ?
I can empathize with you about this. In Germany we have 16 regions and all have their own holiday laws. Some are national, some for a subset of regions - and all is subject to change... :)
Although I would prefer a complete set, a good implementation of the national holidays + perfect Quebec-holidays is very much alright. Let's start here and add the missing bits later.
If it is not too much of a hassle, could you provide the english translation as well, i.e. the (Quebec-biased) en-CA
locale? This way #29 would benefit from your work as well.
Second, I would have liked to do the observed dates as you suggested for the holidays, but in Canada (and Quebec), the choice is left to the employer whether the holiday is observed on the Friday or the Monday if the holiday falls on the weekend. This means it isn't actually the same date for everyone. Would you prefer I simply choose the most probable one (usually the closest one), write both or not handle the observed dates ?
IMHO, keeping it simple is the better choice. Anything that is open to individual choice is something we cannot model (now - but maybe never), so we should better leave it out.
Other than those considerations, I think (probably wrongly, but here's to optimism) I could be ready to create a PR this weekend.
👍 Looking forward to it.
from holidata.
Related Issues (20)
- Holidata.net domain expired? HOT 1
- Holidata.net seams down HOT 1
- Error in locale en-US, year 2024: Day after Thanksgiving HOT 1
- Add locale for es-PE HOT 1
- JsonEmitter returns invalid JSON object HOT 3
- Add locale for sl-SI HOT 1
- Add locale for en-AU HOT 2
- Error in locale fr-FR HOT 2
- Add locale for es-MX
- Add locale for en-india HOT 1
- Add locale for sl-SI HOT 4
- Add locale for en-ZA HOT 1
- Add support for locale en-AU HOT 1
- Error in locale en-GB, year 2022 HOT 1
- [Question] Module not installable from pypi? HOT 1
- Update legal sources for Turkish holidays HOT 1
- Locales for Scotland & Northern ireland HOT 1
- Removal of Columbus Day as an US Holiday
- Add locale for Hi-In (Hindi - India )
- Add locale for en-SG
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from holidata.