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
Add Hong Kong calendar. Factor out the Christmas/Boxing Day Sunday s… #235
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1afc7ac
Add Hong Kong calendar. Factor out the Christmas/Boxing Day Sunday s…
daa2f63
Add the PR number to the change log. How could I have known the numb…
d195c34
Updated to use the label for Boxing Day. Discovered that prior to 20…
0c1edb3
Minor flake change so the line isn't too long
38896d9
Merge branch 'master' of https://github.com/novafloss/workalendar int…
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,7 @@ Europe | |
* France (Alsace / Moselle) | ||
* Germany | ||
* Greece | ||
* Hong Kong | ||
* Hungary | ||
* Iceland | ||
* Ireland | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from datetime import timedelta | ||
|
||
from workalendar.core import ChineseNewYearCalendar, WesternCalendar | ||
from workalendar.core import ChristianMixin, EphemMixin | ||
|
||
|
||
class HongKong(EphemMixin, WesternCalendar, | ||
ChineseNewYearCalendar, ChristianMixin): | ||
"Hong Kong" | ||
include_good_friday = True | ||
include_easter_saturday = True | ||
include_easter_monday = True | ||
include_boxing_day = True | ||
|
||
FIXED_HOLIDAYS = WesternCalendar.FIXED_HOLIDAYS + ( | ||
(5, 1, "Labour Day"), | ||
(7, 1, "SAR Establishment Day"), | ||
(10, 1, "National Day"), | ||
) | ||
|
||
chinese_new_year_label = "Chinese Lunar New Year's Day" | ||
include_chinese_second_day = True | ||
chinese_second_day_label = "Second day of Chinese Lunar New Year" | ||
include_chinese_third_day = True | ||
chinese_third_day_label = "Third day of Chinese Lunar New Year" | ||
shift_sunday_holidays = True # Except CNY which rolls to Saturday | ||
shift_start_cny_sunday = False # Prior to 2011 this was True | ||
|
||
def get_variable_days(self, year): | ||
""" | ||
Hong Kong variable days | ||
""" | ||
|
||
# Prior to the "General Holidays and Employment Legislation | ||
# (Substitution of Holidays)(Amendment) Ordinance 2011", the first day | ||
# of CNY rolled to a Sat if it was on a Sun. After the Amendment, it | ||
# rolls to the following Wed | ||
if year < 2011: | ||
self.shift_start_cny_sunday = True | ||
|
||
days = super(HongKong, self).get_variable_days(year) | ||
chingming = EphemMixin.solar_term(self, year, 15, 'Asia/Hong_Kong') | ||
dupe_holiday = [chingming for day in days if chingming == day[0]] | ||
if dupe_holiday: | ||
# Roll Chingming forward a day as it clashes with another holiday | ||
chingming = chingming + timedelta(days=1) | ||
mid_autumn_label = "Day After Mid-Autumn Festival" | ||
days.extend([ | ||
(ChineseNewYearCalendar.lunar(year, 4, 8), "Buddha's Birthday"), | ||
(chingming, "Ching Ming Festival"), | ||
(ChineseNewYearCalendar.lunar(year, 5, 5), "Tuen Ng Festival"), | ||
(ChineseNewYearCalendar.lunar(year, 8, 16), mid_autumn_label), | ||
(ChineseNewYearCalendar.lunar(year, 9, 9), "Chung Yeung Festival"), | ||
]) | ||
|
||
# Boxing day & XMas shift | ||
shifts = self.shift_christmas_boxing_days(year=year) | ||
days.extend(shifts) | ||
|
||
return days |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can add a docstring here, for more clarity. it's not a blocking point, though