Skip to content

Commit

Permalink
Merge pull request #2 from dr-prodigy/beta
Browse files Browse the repository at this point in the history
Update beta
  • Loading branch information
jusce17 authored Dec 2, 2020
2 parents be844bc + df1acc7 commit fc4b2f5
Show file tree
Hide file tree
Showing 13 changed files with 226 additions and 63 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ before_install:

install:
# hijri-converter not available < python 3.6
# use Python 3.9 to test missing hijri-converter
# $TRAVIS_PYTHON_VERSION == '3.9' ||
- if [[
$TRAVIS_PYTHON_VERSION == '3.9' ||
$TRAVIS_PYTHON_VERSION == '3.8' ||
$TRAVIS_PYTHON_VERSION == '3.7' ||
$TRAVIS_PYTHON_VERSION == '3.6' ||
$TRAVIS_PYTHON_VERSION == 'pypy3'
]]; then pip install hijri-converter; fi
- pip install python-dateutil
- pip install convertdate
- pip install "convertdate<=2.2.0"
- pip install korean_lunar_calendar
- pip install six
- pip install flake8
Expand Down
13 changes: 9 additions & 4 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,24 @@ Released ????? ??, ????
- Support for Djibouti (Abdisamade)
- Support for United Arab Emirates (marcomasulli, mborsetti)
- Support for Chile (mborsetti, dr-p)
- Support for Angola (pietervdw115)
- Korea 2020 fix (MYUNGJE, dr-p)
- Support for Angola (jusce17, pietervdw115, dr-p)
- Support for Malawi (pietervdw115)
- Support for Bangladesh (dr-p, tasnimislam)
- Korea fixes (MYUNGJE, dr-p, hiddentrap)
- Australia 2020 fix (bencollerson, trauty-is-me)
- Croatia fixes and updates (jangrg, mborsetti, dr-p)
- United States fixes (raffg, bgmiles, dr-p)
- UK fixes (dr-p, richard-kunert)
- UK fixes/improvements (dr-p, richard-kunert, emreay-)
- Russia fixes (tserekh)
- Ireland fixes (chiuczek)
- Spain observed holidays fix (sermayoral)
- South Africa observed holidays fix (pietervdw115)
- France fix (mborsetti)
- Mexico fix (mborsetti)
- Singapore 2022 fix (mborsetti)
- Japan 1990-1993 fixes (sakurai-youhei)
- Fix on occasional pop_named exception (mborsetti)
- convertdate fallback if hijri-converter not available (mborsetti)
- convertdate fallback if hijri-converter not available (mborsetti, dr-p)
- enabled Travis tests for python3.9 (mborsetti)
- added flake8 to unittests (mborsetti)

Expand Down
10 changes: 6 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ 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.

.. image:: http://img.shields.io/travis/dr-prodigy/python-holidays.svg
.. image:: http://img.shields.io/travis/dr-prodigy/python-holidays/master
:target: https://travis-ci.org/dr-prodigy/python-holidays

.. image:: http://img.shields.io/coveralls/dr-prodigy/python-holidays.svg
.. image:: http://img.shields.io/coveralls/dr-prodigy/python-holidays/master
:target: https://coveralls.io/r/dr-prodigy/python-holidays

.. image:: http://img.shields.io/pypi/v/holidays.svg
Expand Down Expand Up @@ -102,6 +102,7 @@ Argentina AR/ARG None
Aruba AW/ABW None
Australia AU/AUS prov = **ACT** (default), NSW, NT, QLD, SA, TAS, VIC, WA
Austria AT/AUT prov = 1, 2, 3, 4, 5, 6, 7, 8, **9** (default)
Bangladesh BD/BDG None
Belarus BY/BLR None
Belgium BE/BEL None
Brazil BR/BRA state = AC, AL, AP, AM, BA, CE, DF, ES, GO, MA, MT, MS, MG,
Expand All @@ -117,7 +118,7 @@ Croatia HR/HRV None
Czechia CZ/CZE None
Denmark DK/DNK None
Djibouti DJ/DJI None
Dominican Republic DO/DOM None
DominicanRepublic DO/DOM None
Egypt EG/EGY None
England None
Estonia EE/EST None
Expand Down Expand Up @@ -148,6 +149,7 @@ Korea KR/KOR None
Latvia LV/LVA None
Lithuania LT/LTU None
Luxembourg LU/LUX None
Malawi MW/MWI None
Mexico MX/MEX None
Morocco MA/MOR None
Netherlands NL/NLD None
Expand All @@ -169,7 +171,7 @@ Serbia RS/SRB None
Singapore SG/SGP None
Slovakia SK/SVK None
Slovenia SI/SVN None
South Africa ZA/ZAF None
SouthAfrica ZA/ZAF None
Spain ES/ESP prov = AN, AR, AS, CB, CL, CM, CN, CT, EX, GA, IB, MC,
MD, NC, PV, RI, VC
Sweden SE/SWE None
Expand Down
2 changes: 2 additions & 0 deletions holidays/countries/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .aruba import Aruba, AW, ABW
from .australia import Australia, AU, AUS
from .austria import Austria, AT, AUT
from .bangladesh import Bangladesh, BD, BGD
from .belarus import Belarus, BY, BLR
from .belgium import Belgium, BE, BEL
from .brazil import Brazil, BR, BRA
Expand Down Expand Up @@ -48,6 +49,7 @@
from .latvia import Latvia, LV, LVA
from .lithuania import Lithuania, LT, LTU
from .luxembourg import Luxembourg, LU, LUX
from .malawi import Malawi, MW, MWI
from .mexico import Mexico, MX, MEX
from .morocco import Morocco, MA, MOR
from .netherlands import Netherlands, NL, NLD
Expand Down
55 changes: 55 additions & 0 deletions holidays/countries/bangladesh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*-

# python-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.
#
# Author: tasnim<[email protected]>
# ISO code = BD

from datetime import date
from holidays.constants import FEB, MAR, APR, MAY, AUG, DEC
from holidays.holiday_base import HolidayBase


class Bangladesh(HolidayBase):
# https://mopa.gov.bd/sites/default/files/files/mopa.gov.bd/public_holiday/61c35b73_e335_462a_9bcf_4695b23b6d82/reg4-2019-212.PDF
# https://en.wikipedia.org/wiki/Public_holidays_in_Bangladesh

def __init__(self, **kwargs):
self.country = 'TR'
HolidayBase.__init__(self, **kwargs)

def _populate(self, year):

# 21st Feb
self[date(year, FEB, 21)] = "International Mother's language Day"

# 17th March
self[date(year, MAR, 17)] = "Sheikh Mujibur Rahman's Birthday " \
"and Children's Day"

# 26th March
self[date(year, MAR, 26)] = "Independence Day"

# 14th April
self[date(year, APR, 14)] = "Bengali New Year's Day"

# 1st May
self[date(year, MAY, 1)] = "May Day"

# 15th AUG
self[date(year, AUG, 15)] = "National Mourning Day"

# 16th Dec
self[date(year, DEC, 16)] = "Victory Day"


class BD(Bangladesh):
pass


class BGD(Bangladesh):
pass
31 changes: 24 additions & 7 deletions holidays/countries/japan.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

from dateutil.relativedelta import relativedelta as rd, MO

from holidays.constants import JAN, FEB, MAR, APR, MAY, JUL, AUG, SEP, OCT, \
NOV, DEC
from holidays.constants import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, \
OCT, NOV, DEC
from holidays.holiday_base import HolidayBase


Expand Down Expand Up @@ -73,12 +73,16 @@ def _populate(self, year):
self[date(year, JUL, 20)] = "海の日"
elif year == 2020:
self[date(year, JUL, 23)] = "海の日"
elif year == 2021:
self[date(year, JUL, 22)] = "海の日"
elif year >= 2003:
self[date(year, JUL, 1) + rd(weekday=MO(+3))] = "海の日"

# Mountain Day
if year == 2020:
self[date(year, AUG, 10)] = "山の日"
elif year == 2021:
self[date(year, AUG, 8)] = "山の日"
elif year >= 2016:
self[date(year, AUG, 11)] = "山の日"

Expand All @@ -94,23 +98,35 @@ def _populate(self, year):
# Health and Sports Day
if 1966 <= year <= 1999:
self[date(year, OCT, 10)] = "体育の日"
elif year == 2020:
self[date(year, JUL, 24)] = "体育の日"
elif year >= 2000:
elif 2000 <= year <= 2019:
self[date(year, OCT, 1) + rd(weekday=MO(+2))] = "体育の日"
elif year == 2020:
self[date(year, JUL, 24)] = "スポーツの日"
elif year == 2021:
self[date(year, JUL, 23)] = "スポーツの日"
elif 2022 <= year:
self[date(year, OCT, 1) + rd(weekday=MO(+2))] = "スポーツの日"

# Culture Day
self[date(year, NOV, 3)] = "文化の日"

# Labour Thanksgiving Day
self[date(year, NOV, 23)] = "勤労感謝の日"

# Heisei Emperor's Birthday
# Regarding the Emperor of Heisei
if 1989 <= year <= 2018:
# Heisei Emperor's Birthday
self[date(year, DEC, 23)] = "天皇誕生日"

if year == 1990:
# Enthronement ceremony
self[date(year, NOV, 12)] = "即位礼正殿の儀"

# Regarding the Emperor of Reiwa
if year == 2019:
if year == 1993:
# Marriage ceremony
self[date(year, JUN, 9)] = "結婚の儀"
elif year == 2019:
# Enthronement Day
self[date(year, MAY, 1)] = '天皇の即位の日'
# Enthronement ceremony
Expand Down Expand Up @@ -190,6 +206,7 @@ def _add_substitute_holidays(self, year):
2008, 2014, 2025, 2031, 2036, 2042, 2009, 2015, 2020, 2026,
2037, 2043, 2048)),
(7, 21, (1997,)),
(8, 9, (2021,)),
(8, 12, (2019, 2024, 2030, 2041, 2047)),
(9, 16, (1974, 1985, 1991, 1996, 2002)),
(9, 23, (2024,)),
Expand Down
13 changes: 3 additions & 10 deletions holidays/countries/korea.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,12 @@ def _populate(self, year):
# Independence Movement Day
name = "Independence Movement Day"
independence_date = date(year, MAR, 1)
if self.observed and year >= 2015:
if independence_date.weekday() == SUN:
self[independence_date] = name
self[independence_date + rd(days=+1)] = alt_holiday + name
else:
self[independence_date] = name
else:
self[independence_date] = name
self[independence_date] = name

# Tree Planting Day
name = "Tree Planting Day"
planting_date = date(year, APR, 5)
if self.observed and year >= 1949 and year <= 2007 and year != 1960:
if self.observed and 1949 <= year <= 2007 and year != 1960:
self[planting_date] = name
else:
# removed from holiday since 2007
Expand Down Expand Up @@ -134,7 +127,7 @@ def _populate(self, year):
# Constitution Day
name = "Constitution Day"
constitution_date = date(year, JUL, 17)
if self.observed and year >= 1948 and year <= 2007:
if self.observed and 1948 <= year <= 2007:
self[constitution_date] = name
else:
# removed from holiday since 2008
Expand Down
65 changes: 65 additions & 0 deletions holidays/countries/malawi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# -*- coding: utf-8 -*-

# python-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.
#
# Author: ryanss <[email protected]> (c) 2014-2017
# dr-prodigy <[email protected]> (c) 2017-2020
# Website: https://github.com/dr-prodigy/python-holidays
# License: MIT (see LICENSE file)

from datetime import date

from dateutil.easter import easter
from dateutil.relativedelta import relativedelta as rd

from holidays.constants import TUE, SAT, SUN
from holidays.constants import JAN, FEB, MAR, APR, MAY, JUL, SEP, OCT, NOV, DEC
from holidays.holiday_base import HolidayBase


class Malawi(HolidayBase):

def __init__(self, **kwargs):
# https://www.officeholidays.com/countries/malawi
# https://www.timeanddate.com/holidays/malawi/
self.country = 'MW'
HolidayBase.__init__(self, **kwargs)

def _populate(self, year):
# Observed since 2000
if year > 1999:
self[date(year, 1, 1)] = "New Year's Day"

e = easter(year)
good_friday = e - rd(days=2)
easter_monday = e + rd(days=1)
self[good_friday] = "Good Friday"
self[easter_monday] = "Easter Monday"

self[date(year, JAN, 15)] = "John Chilembwe Day"
self[date(year, MAR, 3)] = "Martyrs Day"
self[date(year, MAY, 1)] = "Labour Day"
self[date(year, MAY, 14)] = "Kamuzu Day"
self[date(year, JUL, 6)] = "Independence Day"
self[date(year, OCT, 15)] = "Mother's Day"
self[date(year, DEC, 25)] = "Christmas Day"
self[date(year, DEC, 26)] = "Boxing Day"

for k, v in list(self.items()):
if self.observed and year > 1994:
if k.weekday() == SUN:
self[k + rd(days=1)] = v + " (Observed)"
elif k.weekday() == SAT:
self[k + rd(days=2)] = v + " (Observed)"


class MW(Malawi):
pass


class MWI(Malawi):
pass
5 changes: 4 additions & 1 deletion holidays/countries/south_africa.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ def _populate(self, year):
# it rolls over to the following Monday
for k, v in list(self.items()):
if self.observed and year > 1994 and k.weekday() == SUN:
self[k + rd(days=1)] = v + " (Observed)"
add_days = 1
while self.get(k + rd(days=add_days)) is not None:
add_days += 1
self[k + rd(days=add_days)] = v + " (Observed)"

# Historic public holidays no longer observed
if 1951 < year < 1974:
Expand Down
Loading

0 comments on commit fc4b2f5

Please sign in to comment.