-
-
Notifications
You must be signed in to change notification settings - Fork 558
Update Ethiopia holidays, add ETHIOPIAN_CALENDAR
support, Julian Date Drift adjustment pre-1899 and post-2099
#2794
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d757e8f
Update Ethiopia holidays, add full `ETHIOPIAN_CALENDAR` support for `…
PPsyrius e42b329
Fix Ethiopian Leap Year logic, move Ethiopian New Year to `Internatio…
PPsyrius 8a281b1
Add test case for `is_previous_year_ethiopian_leap_year` as well
PPsyrius 87a2bba
Merge branch 'dev' into ethiopian_calendar
PPsyrius d7b7405
Julian Calendar Drift Adjustments
PPsyrius bcffa64
Julian Calendar Drift shouldn't affect pre-March 1st, 2100
PPsyrius e2b87fb
Code Comment clarification for Ethiopian New Year
PPsyrius 76703d2
Pre-Commit fixes
PPsyrius 3ef6276
Logic Simplification
PPsyrius 4e5fc05
Further Logic Simplification
PPsyrius 4f6e350
Fix up the code + port our new logic to Ethiopian New Year code as well
PPsyrius f6424a3
Simplify 'Popular Revolution Commemoration Day' (1976-1990) Logic
PPsyrius d11ae11
Merge branch 'dev' into ethiopian_calendar
PPsyrius 2551e24
Merge branch 'dev' into ethiopian_calendar
PPsyrius File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,31 @@ | ||
# holidays | ||
# -------- | ||
# A fast, efficient Python library for generating country, province and state | ||
# specific sets of holidays on the fly. It aims to make determining whether a | ||
# specific date is a holiday as fast and flexible as possible. | ||
# | ||
# Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
# ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
# Website: https://github.com/vacanza/holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
ETHIOPIAN_CALENDAR = "ETHIOPIAN_CALENDAR" | ||
|
||
|
||
def is_ethiopian_leap_year(year: int) -> bool: | ||
"""Determine if the Ethiopian year that starts in the given Gregorian year is a leap year. | ||
|
||
Ethiopian leap years follow the Coptic/Julian rule: | ||
* Every 4 years without exception (no century rule). | ||
* The Ethiopian year starts on September 11 (or 12 in an Ethiopian leap year). | ||
|
||
Args: | ||
year: | ||
Gregorian year to evaluate. | ||
|
||
Returns: | ||
`True` if an Ethiopian leap year starts in the given Gregorian year, `False` otherwise. | ||
""" | ||
|
||
return (year + 1) % 4 == 0 |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,37 @@ | ||
# holidays | ||
# -------- | ||
# A fast, efficient Python library for generating country, province and state | ||
# specific sets of holidays on the fly. It aims to make determining whether a | ||
# specific date is a holiday as fast and flexible as possible. | ||
# | ||
# Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
# ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
# Website: https://github.com/vacanza/holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
import unittest | ||
|
||
from holidays.calendars.ethiopian import is_ethiopian_leap_year | ||
|
||
|
||
class TestEthiopianCalendar(unittest.TestCase): | ||
def test_is_ethiopian_leap_year(self): | ||
known_ethiopian_leap_years = { | ||
# Known Cases. | ||
2022: False, | ||
2023: True, | ||
2024: False, | ||
2025: False, | ||
# Future Cases. | ||
2098: False, | ||
2099: True, | ||
2100: False, | ||
2101: False, | ||
2198: False, | ||
2199: True, | ||
2200: False, | ||
2201: False, | ||
} | ||
PPsyrius marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for year in known_ethiopian_leap_years: | ||
self.assertEqual(known_ethiopian_leap_years[year], is_ethiopian_leap_year(year)) | ||
PPsyrius marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or 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,36 @@ | ||
# holidays | ||
# -------- | ||
# A fast, efficient Python library for generating country, province and state | ||
# specific sets of holidays on the fly. It aims to make determining whether a | ||
# specific date is a holiday as fast and flexible as possible. | ||
# | ||
# Authors: Vacanza Team and individual contributors (see CONTRIBUTORS file) | ||
# dr-prodigy <dr.prodigy.github@gmail.com> (c) 2017-2023 | ||
# ryanss <ryanssdev@icloud.com> (c) 2014-2017 | ||
# Website: https://github.com/vacanza/holidays | ||
# License: MIT (see LICENSE file) | ||
|
||
import unittest | ||
|
||
from holidays.calendars.julian import julian_calendar_drift | ||
|
||
|
||
class TestJulianCalendar(unittest.TestCase): | ||
def test_julian_calendar_drift(self): | ||
known_julian_calendar_drift = { | ||
1400: -13, | ||
1500: -13, | ||
1581: -13, | ||
1582: -13, | ||
1583: -3, | ||
1600: -3, | ||
1700: -2, | ||
1800: -1, | ||
1900: 0, | ||
2000: 0, | ||
2025: 0, | ||
2100: +1, | ||
2200: +2, | ||
} | ||
for year in known_julian_calendar_drift: | ||
self.assertEqual(known_julian_calendar_drift[year], julian_calendar_drift(year)) | ||
PPsyrius marked this conversation as resolved.
Show resolved
Hide resolved
|
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.
Uh oh!
There was an error while loading. Please reload this page.