Skip to content

Commit

Permalink
Merge pull request #2232 from vacanza/dev
Browse files Browse the repository at this point in the history
v0.65
  • Loading branch information
arkid15r authored Jan 20, 2025
2 parents 48e4fdd + b254f8d commit 3b82ecf
Show file tree
Hide file tree
Showing 25 changed files with 576 additions and 338 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ jobs:

- name: Compute SHA1 checksums
run: |
for file in dist/*; do
cd dist
for file in *; do
sha1sum "$file" > "$file.sha1"
done
Expand All @@ -283,7 +284,7 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: signed-artifacts
path: dist/
path: dist

update-github-release:
name: Update GitHub release with SBOM and signed artifacts
Expand All @@ -302,6 +303,7 @@ jobs:
uses: actions/download-artifact@v4
with:
name: signed-artifacts
path: dist

- name: Update Github release
env:
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ repos:
- --py39-plus

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.2
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -39,7 +39,7 @@ repos:
- docs/file_header.txt

- repo: https://github.com/pycqa/bandit
rev: 1.8.0
rev: 1.8.2
hooks:
- id: bandit
additional_dependencies:
Expand Down
14 changes: 13 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
Version 0.65
============

Released January 20, 2025

- Update Afghanistan and Iran holidays: change weekend to FRI-SAT and FRI respectively (#2223 by @gio8tisu, @arkid15r)
- Update Afghanistan holidays (#2221 by @KJhellico)
- Update South Korea holidays: 2025 temporary public holidays (#2218 by @YiGeon)
- Update ruff from v0.8.6 to v0.9.1 (#2224 by @arkid15r)
- Add faster date parsing from strings in ISO 8601 format (#2227 by @KJhellico)
- Add signed artifacts path (#2216 by @arkid15r)

Version 0.64
============

Expand All @@ -18,7 +30,7 @@ Released January 6, 2025
- Add Norway holidays localization: th (#2200 by @ansntu)
- Add Russia holidays localization: th (#2190 by @PPsyrius, @arkid15r)
- Add Ukraine holidays localization: th (#2189 by @PPsyrius, @arkid15r)
- Sign release artifacts using Sigstore (#2195 by @arkid15r
- Sign release artifacts using Sigstore (#2195 by @arkid15r)

Version 0.63
============
Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

| Version | Supported |
| ------- | ------------------ |
| 0.64 | :white_check_mark: |
| < 0.64 | :x: |
| 0.65 | :white_check_mark: |
| < 0.65 | :x: |

## Reporting a Vulnerability

Expand Down
124 changes: 106 additions & 18 deletions holidays/countries/afghanistan.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,46 @@

from gettext import gettext as tr

from holidays.groups import InternationalHolidays, IslamicHolidays
from holidays.calendars import _CustomIslamicHolidays
from holidays.calendars.gregorian import (
JAN,
MAR,
APR,
MAY,
JUN,
JUL,
AUG,
SEP,
OCT,
NOV,
DEC,
FRI,
SAT,
)
from holidays.groups import InternationalHolidays, IslamicHolidays, PersianCalendarHolidays
from holidays.holiday_base import HolidayBase


class Afghanistan(HolidayBase, InternationalHolidays, IslamicHolidays):
class Afghanistan(HolidayBase, InternationalHolidays, IslamicHolidays, PersianCalendarHolidays):
"""
https://en.wikipedia.org/wiki/Public_holidays_in_Afghanistan
https://www.timeanddate.com/holidays/afghanistan/
https://en.wikipedia.org/wiki/Workweek_and_weekend
"""

country = "AF"
default_language = "fa_AF"
# %s (estimated).
estimated_label = tr("%s (برآورد شده)")
# %s (observed).
observed_label = tr("%s (مشاهده شده)")
# %s (observed, estimated).
observed_estimated_label = tr("%s (مشاهده شده، برآورد شده)")
supported_languages = ("en_US", "fa_AF", "ps_AF")
# Afghanistan's regaining of full independence from British influence.
start_year = 1919
weekend = {FRI, SAT}

def __init__(self, *args, **kwargs):
InternationalHolidays.__init__(self)
IslamicHolidays.__init__(self)
IslamicHolidays.__init__(self, AfghanistanIslamicHolidays)
PersianCalendarHolidays.__init__(self)
super().__init__(*args, **kwargs)

def _populate_public_holidays(self):
Expand All @@ -49,7 +64,7 @@ def _populate_public_holidays(self):

if self._year <= 1996 or 2001 <= self._year <= 2020:
# Nowruz.
self._add_holiday_mar_21(tr("نوروز"))
self._add_nowruz_day(tr("نوروز"))

if self._year >= 1992:
# Mojahedin's Victory Day.
Expand All @@ -64,13 +79,26 @@ def _populate_public_holidays(self):
self._add_holiday_may_9(tr("روز پیروزی شوروی"))

if self._year >= 2022:
# Islamic Emirate Victory Day.
self._add_islamic_emirat_victory_day(tr("روز پیروزی امارت اسلامی"))

# American Withdrawal Day.
self._add_holiday_aug_31(tr("روز خروج آمریکایی ها"))

if self._year >= 2012:
if 2012 <= self._year <= 2020:
# Martyrs' Day.
self._add_holiday_sep_9(tr("روز شهیدان"))

if self._year <= 2021:
# Ashura.
self._add_ashura_day(tr("عاشورا"))

# Prophet's Birthday.
self._add_mawlid_day(tr("میلاد پیامبر"))

# First Day of Ramadan.
self._add_ramadan_beginning_day(tr("اول رمضان"))

# Eid al-Fitr.
name = tr("عید فطر")
self._add_eid_al_fitr_day(name)
Expand All @@ -86,19 +114,79 @@ def _populate_public_holidays(self):
self._add_eid_al_adha_day_two(name)
self._add_eid_al_adha_day_three(name)

# Ashura.
self._add_ashura_day(tr("عاشورا"))

# First Day of Ramadan.
self._add_ramadan_beginning_day(tr("اول رمضان"))

# Prophet's Birthday.
self._add_mawlid_day(tr("میلاد پیامبر"))


class AF(Afghanistan):
pass


class AFG(Afghanistan):
pass


class AfghanistanIslamicHolidays(_CustomIslamicHolidays):
ASHURA_DATES = {
2014: (NOV, 3),
2015: (OCT, 24),
2016: (OCT, 12),
2017: (OCT, 1),
2018: (SEP, 21),
2019: (SEP, 10),
2020: (AUG, 30),
2021: (AUG, 19),
}

EID_AL_ADHA_DATES = {
2014: (OCT, 5),
2015: (SEP, 23),
2016: (SEP, 13),
2017: (SEP, 2),
2018: (AUG, 22),
2019: (AUG, 11),
2020: (JUL, 31),
2021: (JUL, 20),
2022: (JUL, 9),
2023: (JUN, 28),
2024: (JUN, 17),
}

EID_AL_FITR_DATES = {
2014: (JUL, 29),
2015: (JUL, 18),
2016: (JUL, 7),
2017: (JUN, 26),
2018: (JUN, 15),
2019: (JUN, 4),
2020: (MAY, 24),
2021: (MAY, 13),
2022: (MAY, 1),
2023: (APR, 22),
2024: (APR, 10),
}

MAWLID_DATES = {
2014: (JAN, 14),
2015: ((JAN, 3), (DEC, 24)),
2016: (DEC, 12),
2017: (DEC, 1),
2018: (NOV, 21),
2019: (NOV, 10),
2020: (OCT, 29),
2021: (OCT, 19),
2022: (OCT, 8),
2023: (SEP, 27),
2024: (SEP, 16),
}

RAMADAN_BEGINNING_DATES = {
2014: (JUN, 29),
2015: (JUN, 18),
2016: (JUN, 7),
2017: (MAY, 27),
2018: (MAY, 16),
2019: (MAY, 6),
2020: (APR, 24),
2021: (APR, 13),
2022: (APR, 2),
2023: (MAR, 23),
2024: (MAR, 11),
}
3 changes: 3 additions & 0 deletions holidays/countries/iran.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

from gettext import gettext as tr

from holidays.calendars.gregorian import FRI
from holidays.groups import IslamicHolidays, PersianCalendarHolidays
from holidays.holiday_base import HolidayBase

Expand All @@ -21,6 +22,7 @@ class Iran(HolidayBase, IslamicHolidays, PersianCalendarHolidays):
References:
- https://en.wikipedia.org/wiki/Public_holidays_in_Iran
- https://fa.wikipedia.org/wiki/تعطیلات_عمومی_در_ایران
- https://en.wikipedia.org/wiki/Workweek_and_weekend
"""

country = "IR"
Expand All @@ -29,6 +31,7 @@ class Iran(HolidayBase, IslamicHolidays, PersianCalendarHolidays):
estimated_label = tr("(تخمین زده) %s")
supported_languages = ("en_US", "fa")
start_year = 1980
weekend = {FRI}

def __init__(self, *args, **kwargs):
IslamicHolidays.__init__(self)
Expand Down
5 changes: 1 addition & 4 deletions holidays/countries/lithuania.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ def _populate_public_holidays(self) -> None:
if self._year >= 1991:
self._add_holiday_jul_6(
# Statehood Day.
tr(
"Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) "
"ir Tautiškos giesmės diena"
)
tr("Valstybės (Lietuvos karaliaus Mindaugo karūnavimo) ir Tautiškos giesmės diena")
)

# Assumption Day.
Expand Down
2 changes: 2 additions & 0 deletions holidays/countries/south_korea.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,6 +617,8 @@ class SouthKoreaStaticHolidays:
2023: (OCT, 2, temporary_public_holiday),
# 76th Anniversary of the Armed Forces of Korea.
2024: (OCT, 1, armed_forces_day),
# Added to create a 6-day long holiday period.
2025: (JAN, 27, temporary_public_holiday),
}
# Pre-2014 Alternate Holidays
# https://namu.wiki/w/대체%20휴일%20제도#s-4.2.1
Expand Down
3 changes: 1 addition & 2 deletions holidays/countries/thailand.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,7 @@ def _populate_public_holidays(self):
if self._year >= 2019:
# HM King Bhumibol Adulyadej the Great's Birthday Anniversary.
name = tr(
"วันคล้ายวันเฉลิมพระชนมพรรษาพระบาทสมเด็จพระบรมชนกาธิเบศร "
"มหาภูมิพลอดุลยเดชมหาราช บรมนาถบพิตร"
"วันคล้ายวันเฉลิมพระชนมพรรษาพระบาทสมเด็จพระบรมชนกาธิเบศร มหาภูมิพลอดุลยเดชมหาราช บรมนาถบพิตร"
)
elif self._year >= 2016:
# HM King Bhumibol Adulyadej Birthday Anniversary.
Expand Down
11 changes: 11 additions & 0 deletions holidays/groups/persian.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ def _add_death_of_khomeini_day(self, name: str) -> Optional[date]:
name, self._persian_calendar.persian_to_gregorian(self._year, 3, 14)
)

def _add_islamic_emirat_victory_day(self, name: str) -> Optional[date]:
"""
Add Islamic Emirate Victory Day (24th day of the 5th month).
Anniversary of the Taliban forces arrival in Kabul.
https://en.wikipedia.org/wiki/Fall_of_Kabul_(2021)
"""
return self._add_persian_calendar_holiday(
name, self._persian_calendar.persian_to_gregorian(self._year, 5, 24)
)

def _add_islamic_republic_day(self, name: str) -> Optional[date]:
"""
Add Islamic Republic Day (12th day of the 1st month).
Expand Down
19 changes: 13 additions & 6 deletions holidays/holiday_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,8 +329,7 @@ def __init__(
# Deprecated arguments.
if prov_state := prov or state:
warnings.warn(
"Arguments prov and state are deprecated, use "
f"subdiv='{prov_state}' instead.",
f"Arguments prov and state are deprecated, use subdiv='{prov_state}' instead.",
DeprecationWarning,
)

Expand Down Expand Up @@ -585,6 +584,7 @@ def __keytransform__(self, key: DateLike) -> date:
to :class:`datetime.date`, which is how it's stored by the class."""

dt: Optional[date] = None
# Try to catch `date` and `str` type keys first.
# Using type() here to skip date subclasses.
# Key is `date`.
Expand All @@ -593,10 +593,17 @@ def __keytransform__(self, key: DateLike) -> date:

# Key is `str` instance.
elif isinstance(key, str):
try:
dt = parse(key).date()
except (OverflowError, ValueError):
raise ValueError(f"Cannot parse date from string '{key}'")
# key possibly contains a date in YYYY-MM-DD or YYYYMMDD format.
if len(key) in {8, 10}:
try:
dt = date.fromisoformat(key)
except ValueError:
pass
if dt is None:
try:
dt = parse(key).date()
except (OverflowError, ValueError):
raise ValueError(f"Cannot parse date from string '{key}'")

# Key is `datetime` instance.
elif isinstance(key, datetime):
Expand Down
Loading

0 comments on commit 3b82ecf

Please sign in to comment.