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

Update Vietnam holidays #2049

Merged
merged 1 commit into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
139 changes: 115 additions & 24 deletions holidays/countries/vietnam.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,49 @@
# Website: https://github.com/vacanza/holidays
# License: MIT (see LICENSE file)

from datetime import date
from gettext import gettext as tr

from holidays.groups import ChineseCalendarHolidays, InternationalHolidays
from holidays.observed_holiday_base import ObservedHolidayBase, SAT_SUN_TO_NEXT_WORKDAY


class Vietnam(ObservedHolidayBase, ChineseCalendarHolidays, InternationalHolidays):
from holidays.calendars.gregorian import (
JAN,
FEB,
APR,
MAY,
SEP,
DEC,
MON,
TUE,
WED,
THU,
FRI,
SAT,
SUN,
_timedelta,
)
from holidays.groups import ChineseCalendarHolidays, InternationalHolidays, StaticHolidays
from holidays.observed_holiday_base import (
ObservedHolidayBase,
ObservedRule,
SAT_TO_PREV_WORKDAY,
SUN_TO_NEXT_WORKDAY,
SAT_SUN_TO_NEXT_WORKDAY,
)

NATIONAL_DAY_RULE = ObservedRule({MON: +1, TUE: -1, WED: -1, THU: +1, FRI: -1, SAT: -1, SUN: +1})


class Vietnam(ObservedHolidayBase, ChineseCalendarHolidays, InternationalHolidays, StaticHolidays):
"""
https://publicholidays.vn/
http://vbpl.vn/TW/Pages/vbpqen-toanvan.aspx?ItemID=11013 Article.115
https://www.timeanddate.com/holidays/vietnam/
References:
- `Labor Code 1994 (Art. 73) (en) <https://vbpl.vn/TW/Pages/vbpqen-toanvan.aspx?ItemID=2835>`_
- `Labor Code 2012 (Art. 115) (en) <https://vbpl.vn/TW/Pages/vbpqen-toanvan.aspx?ItemID=11013>`_
- `Labor Code 2012 (Art. 115) (vi) <https://vbpl.vn/TW/Pages/vbpq-toanvan.aspx?ItemID=27615>`_
- `Labor Code 2019 (Art. 112) (en) <https://vbpl.vn/TW/Pages/vbpqen-toanvan.aspx?ItemID=11135>`_
- `Labor Code 2019 (Art. 112) (vi) <https://vbpl.vn/TW/Pages/vbpq-van-ban-goc.aspx?ItemID=139264>`_

Substituted holidays:
- `2018-2019 <https://thuvienphapluat.vn/cong-van/EN/Lao-dong-Tien-luong/Official-Dispatch-6519-VPCP-KGVX-2018-national-holidays-for-public-sector-employees/387625/tieng-anh.aspx>`_
- `2024 <https://thuvienphapluat.vn/cong-van/EN/Lao-dong-Tien-luong/Official-Dispatch-2450-VPCP-KGVX-2024-swap-of-working-days-during-the-Reunification-Day/606458/tieng-anh.aspx>`_
"""

country = "VN"
Expand All @@ -32,47 +64,81 @@ class Vietnam(ObservedHolidayBase, ChineseCalendarHolidays, InternationalHoliday
def __init__(self, *args, **kwargs):
ChineseCalendarHolidays.__init__(self)
InternationalHolidays.__init__(self)
StaticHolidays.__init__(self, VietnamStaticHolidays)
kwargs.setdefault("observed_rule", SAT_SUN_TO_NEXT_WORKDAY)
kwargs.setdefault("observed_since", 1995)
super().__init__(*args, **kwargs)

def _add_lunar_new_year_observed(self, dt_lny: date) -> None:
if self._year <= 1994:
return None

day_names = {
# 29 of Lunar New Year.
-2: tr("29 Tết"),
KJhellico marked this conversation as resolved.
Show resolved Hide resolved
# Fourth Day of Lunar New Year.
3: tr("Mùng bốn Tết Nguyên Đán"),
# Fifth Day of Lunar New Year.
4: tr("Mùng năm Tết Nguyên Đán"),
# Sixth Day of Lunar New Year.
5: tr("Mùng sáu Tết Nguyên Đán"),
}
for delta in range(-1, 4 if self._year >= 2013 else 3):
dt = _timedelta(dt_lny, delta)
dt_observed = self._get_observed_date(
dt,
rule=(
SAT_TO_PREV_WORKDAY + SUN_TO_NEXT_WORKDAY
if self._year >= 2014
else SAT_SUN_TO_NEXT_WORKDAY
),
)
if dt_observed != dt:
self._add_holiday(
day_names[(dt_observed - dt_lny).days], # type: ignore[operator]
dt_observed,
)

def _populate_public_holidays(self):
dts_observed = set()

# New Year's Day
# New Year's Day.
dts_observed.add(self._add_new_years_day(tr("Tết Dương lịch")))

# Lunar New Year's Eve
# Lunar New Year's Eve.
self._add_chinese_new_years_eve(tr("Giao thừa Tết Nguyên Đán"))

# Lunar New Year
self._add_chinese_new_years_day(tr("Tết Nguyên Đán"))
# Lunar New Year.
lny = self._add_chinese_new_years_day(tr("Tết Nguyên Đán"))

# Second Day of Lunar New Year
# Second Day of Lunar New Year.
self._add_chinese_new_years_day_two(tr("Mùng hai Tết Nguyên Đán"))

# Third Day of Lunar New Year
# Third Day of Lunar New Year.
self._add_chinese_new_years_day_three(tr("Mùng ba Tết Nguyên Đán"))

# Fourth Day of Lunar New Year
self._add_chinese_new_years_day_four(tr("Mùng bốn Tết Nguyên Đán"))

# Fifth Day of Lunar New Year
self._add_chinese_new_years_day_five(tr("Mùng năm Tết Nguyên Đán"))
if self._year >= 2013:
# Fourth Day of Lunar New Year.
self._add_chinese_new_years_day_four(tr("Mùng bốn Tết Nguyên Đán"))

if self._year >= 2007:
# Hung Kings' Commemoration Day
# Hung Kings' Commemoration Day.
dts_observed.add(self._add_hung_kings_day(tr("Ngày Giỗ Tổ Hùng Vương")))

# Liberation Day/Reunification Day
# Liberation Day/Reunification Day.
dts_observed.add(self._add_holiday_apr_30(tr("Ngày Chiến thắng")))

# International Labor Day
# International Labor Day.
dts_observed.add(self._add_labor_day(tr("Ngày Quốc tế Lao động")))

# National Day
dts_observed.add(self._add_holiday_sep_2(tr("Quốc khánh")))
# National Day.
name = tr("Quốc khánh")
dts_observed.add(sep_2 := self._add_holiday_sep_2(name))
if self._year >= 2021:
self._add_holiday(name, self._get_observed_date(sep_2, NATIONAL_DAY_RULE))

if self.observed:
self._add_lunar_new_year_observed(lny)
self._populate_observed(dts_observed)


Expand All @@ -82,3 +148,28 @@ class VN(Vietnam):

class VNM(Vietnam):
pass


class VietnamStaticHolidays:
# Date format (see strftime() Format Codes).
substituted_date_format = tr("%d/%m/%Y")
# Day off (substituted from %s).
substituted_label = tr("Ngày nghỉ (thay cho ngày %s)")

special_public_holidays = {
2010: (FEB, 19, FEB, 27),
2012: (JAN, 27, FEB, 4),
2013: (APR, 29, MAY, 4),
2014: (
(MAY, 2, APR, 26),
(SEP, 1, SEP, 6),
),
2015: (
(JAN, 2, DEC, 27, 2014),
(FEB, 16, FEB, 14),
(APR, 29, APR, 25),
),
2018: (DEC, 31, JAN, 5, 2019),
2019: (APR, 29, MAY, 4),
2024: (APR, 29, MAY, 4),
}
10 changes: 0 additions & 10 deletions holidays/groups/chinese.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,6 @@ def _add_chinese_new_years_day_four(self, name) -> Optional[date]:
name, self._chinese_calendar.lunar_new_year_date(self._year), days_delta=+3
)

def _add_chinese_new_years_day_five(self, name) -> Optional[date]:
"""
Add Chinese New Year's Day Five.

https://en.wikipedia.org/wiki/Chinese_New_Year
"""
return self._add_chinese_calendar_holiday(
name, self._chinese_calendar.lunar_new_year_date(self._year), days_delta=+4
)

def _add_qingming_festival(self, name) -> date:
"""
Add Qingming Festival (15th day after the Spring Equinox).
Expand Down
56 changes: 37 additions & 19 deletions holidays/locale/en_US/LC_MESSAGES/VN.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,80 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Holidays 0.58\n"
"Project-Id-Version: Holidays 0.59\n"
"POT-Creation-Date: 2024-09-27 15:50+0700\n"
"PO-Revision-Date: 2024-09-27 15:50+0700\n"
"Last-Translator: Vu Nhat Chuong <ronnyvu321@gmail.com>\n"
"PO-Revision-Date: 2024-10-09 20:57+0300\n"
"Last-Translator: ~Jhellico <jhellico@gmail.com>\n"
"Language-Team: Holidays Localization Team\n"
"Language: vi\n"
"Language: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Lingva 5.0.4\n"
"X-Generator: Poedit 3.5\n"

#. %s (observed).
#, c-format
msgid "%s (nghỉ bù)"
msgstr "%s (observed)"

#. New Year's Day
#. New Year's Day.
msgid "Tết Dương lịch"
msgstr "New Year's Day"

#. Lunar New Year's Eve
#. 29 of Lunar New Year.
msgid "29 Tết"
msgstr "29 of Lunar New Year"

#. Lunar New Year's Eve.
msgid "Giao thừa Tết Nguyên Đán"
msgstr "Lunar New Year's Eve"

#. Lunar New Year
#. Lunar New Year.
msgid "Tết Nguyên Đán"
msgstr "Lunar New Year"

#. Second Day of Lunar New Year
#. Second Day of Lunar New Year.
msgid "Mùng hai Tết Nguyên Đán"
msgstr "The second day of Tet Holiday"
msgstr "Second Day of Lunar New Year"

#. Third Day of Lunar New Year
#. Third Day of Lunar New Year.
msgid "Mùng ba Tết Nguyên Đán"
msgstr "The third day of Tet Holiday"
msgstr "Third Day of Lunar New Year"

#. Fourth Day of Lunar New Year
#. Fourth Day of Lunar New Year.
msgid "Mùng bốn Tết Nguyên Đán"
msgstr "The fourth day of Tet Holiday"
msgstr "Fourth Day of Lunar New Year"

#. Fifth Day of Lunar New Year
#. Fifth Day of Lunar New Year.
msgid "Mùng năm Tết Nguyên Đán"
msgstr "The fifth day of Tet Holiday"
msgstr "Fifth Day of Lunar New Year"

#. Sixth Day of Lunar New Year.
msgid "Mùng sáu Tết Nguyên Đán"
msgstr "Sixth Day of Lunar New Year"

#. Hung Kings' Commemoration Day
#. Hung Kings' Commemoration Day.
msgid "Ngày Giỗ Tổ Hùng Vương"
msgstr "Hung Kings' Commemoration Day"

#. Liberation Day/Reunification Day
#. Liberation Day/Reunification Day.
msgid "Ngày Chiến thắng"
msgstr "Liberation Day/Reunification Day"

#. International Labor Day
#. International Labor Day.
msgid "Ngày Quốc tế Lao động"
msgstr "International Labor Day"

#. National Day
#. National Day.
msgid "Quốc khánh"
msgstr "National Day"

#. Date format (see strftime() Format Codes).
msgid "%d/%m/%Y"
msgstr "%m/%d/%Y"

#. Day off (substituted from %s).
#, c-format
msgid "Ngày nghỉ (thay cho ngày %s)"
msgstr "Day off (substituted from %s)"
46 changes: 32 additions & 14 deletions holidays/locale/vi/LC_MESSAGES/VN.po
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,80 @@
#
msgid ""
msgstr ""
"Project-Id-Version: Holidays 0.58\n"
"Project-Id-Version: Holidays 0.59\n"
"POT-Creation-Date: 2024-09-27 15:50+0700\n"
"PO-Revision-Date: 2024-09-27 15:50+0700\n"
"Last-Translator: Vu Nhat Chuong <ronnyvu321@gmail.com>\n"
"PO-Revision-Date: 2024-10-09 20:58+0300\n"
"Last-Translator: ~Jhellico <jhellico@gmail.com>\n"
"Language-Team: Holidays Localization Team\n"
"Language: vi\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Lingva 5.0.4\n"
"X-Generator: Poedit 3.5\n"

#. %s (observed).
#, c-format
msgid "%s (nghỉ bù)"
msgstr ""

#. New Year's Day
#. New Year's Day.
msgid "Tết Dương lịch"
msgstr ""

#. Lunar New Year's Eve
#. 29 of Lunar New Year.
msgid "29 Tết"
msgstr ""

#. Lunar New Year's Eve.
msgid "Giao thừa Tết Nguyên Đán"
msgstr ""

#. Lunar New Year
#. Lunar New Year.
msgid "Tết Nguyên Đán"
msgstr ""

#. Second Day of Lunar New Year
#. Second Day of Lunar New Year.
msgid "Mùng hai Tết Nguyên Đán"
msgstr ""

#. Third Day of Lunar New Year
#. Third Day of Lunar New Year.
msgid "Mùng ba Tết Nguyên Đán"
msgstr ""

#. Fourth Day of Lunar New Year
#. Fourth Day of Lunar New Year.
msgid "Mùng bốn Tết Nguyên Đán"
msgstr ""

#. Fifth Day of Lunar New Year
#. Fifth Day of Lunar New Year.
msgid "Mùng năm Tết Nguyên Đán"
msgstr ""

#. Hung Kings' Commemoration Day
#. Sixth Day of Lunar New Year.
msgid "Mùng sáu Tết Nguyên Đán"
msgstr ""

#. Hung Kings' Commemoration Day.
msgid "Ngày Giỗ Tổ Hùng Vương"
msgstr ""

#. Liberation Day/Reunification Day
#. Liberation Day/Reunification Day.
msgid "Ngày Chiến thắng"
msgstr ""

#. International Labor Day
#. International Labor Day.
msgid "Ngày Quốc tế Lao động"
msgstr ""

#. National Day
#. National Day.
msgid "Quốc khánh"
msgstr ""

#. Date format (see strftime() Format Codes).
msgid "%d/%m/%Y"
msgstr ""

#. Day off (substituted from %s).
#, c-format
msgid "Ngày nghỉ (thay cho ngày %s)"
msgstr ""
Loading