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

Add Hong Kong calendar. Factor out the Christmas/Boxing Day Sunday s… #235

Merged
merged 5 commits into from Jul 3, 2017

Conversation

nedlowe
Copy link
Contributor

@nedlowe nedlowe commented Jun 25, 2017

…hift as its used in the UK and in HK. Add a test to Poland as an example to ensure it doesn't shift countries which don't shift Christmas. Add complicated Sunday shift for the third day of CNY - I would rather loop this than hardcode it, but I didn't want to change the core approach until it had been discussed.

refs #

For information, read and make sure you're okay with the CONTRIBUTING document.

  • Tests with a significant number of years to be tested for your calendar.
  • Docstrings for the Calendar class and specific methods.
  • Calendar country / label added to the README.rst file,
  • Changelog amended with a mention like: "Added <country> by @pseudo (#)"

Ned Lowe added 2 commits June 25, 2017 18:59
…ift as its used in the UK and in HK. Add a test to Poland as an example to ensure it *doesn't* shift countries which don't shift Christmas. Add complicated Sunday shift for the third day of CNY - I would rather loop this than hardcode it, but I didn't want to change the core approach until it had been discussed.
…r before the PR (hence why I split it)? Probably something obvious I missed.
@brunobord
Copy link
Member

It's weird to have all these changes at once, but it looks fine: thanks to our tests, it's obvious that you didn't break a thing!

Don't worry about the fact that it's "hardcoded" in some way, we can refactor this bit later on.

@nedlowe
Copy link
Contributor Author

nedlowe commented Jun 26, 2017 via email

Copy link
Member

@brunobord brunobord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor changes, overall I think it fixes the "D.R.Y." problem and you're adding a valuable new calendar!

@@ -327,6 +327,19 @@ def get_whit_sunday(self, year):
def get_corpus_christi(self, year):
return self.get_easter_sunday(year) + timedelta(days=60)

def shift_christmas_boxing_days(self, year):
Copy link
Member

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

if christmas.weekday() in self.get_weekend_days():
shift = self.find_following_working_day(christmas)
results.append((shift, "Christmas Shift"))
results.append((shift + timedelta(days=1), "Boxing Day Shift"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see the following label here: "{} Shift".format(self.boxing_day_label)
In some countries, Boxing Day is named "St Stephen's" or "The Day After Christmas", for example

results.append((shift + timedelta(days=1), "Boxing Day Shift"))
elif boxing_day.weekday() in self.get_weekend_days():
shift = self.find_following_working_day(boxing_day)
results.append((shift, "Boxing Day Shift"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

Ned Lowe added 3 commits July 2, 2017 21:06
…1, if CNY started on a Sunday it was rolled to a Saturday. This was changed in 2011 since most people had Sat off anyone, and so they made it the following Wed. How very kind of them. Also captured the edge case when chingming falls on the same day as another holiday (most likely a Christian variable holiday such as Easter).
…o hong-kong

* 'master' of https://github.com/novafloss/workalendar:
  Splitted `africa.py` file into an `africa/` module
@nedlowe
Copy link
Contributor Author

nedlowe commented Jul 2, 2017

Hey - sorry for the delay, real life got in the way ;-)

OK I've done the requested changes, plus also fixed a couple of other edge cases I found while researching the Hong Kong calendar (see commit message for details).

@brunobord brunobord merged commit 3bb079a into workalendar:master Jul 3, 2017
@brunobord
Copy link
Member

Thanks a lot for this contribution!

@nedlowe
Copy link
Contributor Author

nedlowe commented Jul 3, 2017

My pleasure! I look forward to being able to contribute more.

@nedlowe nedlowe deleted the hong-kong branch August 17, 2017 06:44
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

Successfully merging this pull request may close these issues.

None yet

2 participants