some new features
This commit is contained in:
@ -0,0 +1,28 @@
|
||||
# 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)
|
||||
|
||||
# ruff: noqa: F401
|
||||
|
||||
from holidays.calendars.balinese_saka import _BalineseSakaLunar
|
||||
from holidays.calendars.buddhist import _BuddhistLunisolar, _CustomBuddhistHolidays
|
||||
from holidays.calendars.chinese import _ChineseLunisolar, _CustomChineseHolidays
|
||||
from holidays.calendars.custom import _CustomCalendar
|
||||
from holidays.calendars.gregorian import GREGORIAN_CALENDAR
|
||||
from holidays.calendars.hebrew import _HebrewLunisolar
|
||||
from holidays.calendars.hindu import _CustomHinduHolidays, _HinduLunisolar
|
||||
from holidays.calendars.islamic import _CustomIslamicHolidays, _IslamicLunar
|
||||
from holidays.calendars.julian import JULIAN_CALENDAR
|
||||
from holidays.calendars.julian_revised import JULIAN_REVISED_CALENDAR
|
||||
from holidays.calendars.mongolian import _CustomMongolianHolidays, _MongolianLunisolar
|
||||
from holidays.calendars.persian import _Persian
|
||||
from holidays.calendars.sinhala import _SinhalaLunar, _CustomSinhalaHolidays
|
||||
from holidays.calendars.thai import _ThaiLunisolar, KHMER_CALENDAR, THAI_CALENDAR
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,112 @@
|
||||
# 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)
|
||||
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from holidays.calendars.gregorian import MAR, APR
|
||||
|
||||
NYEPI = "NYEPI"
|
||||
|
||||
|
||||
class _BalineseSakaLunar:
|
||||
"""
|
||||
Balinese Saka lunar calendar.
|
||||
|
||||
The Balinese saka calendar is one of two calendars used on the Indonesian island
|
||||
of Bali. Unlike the 210-day pawukon calendar, it is based on the phases of the Moon,
|
||||
and is approximately the same length as the tropical year (solar year, Gregorian year).
|
||||
https://en.wikipedia.org/wiki/Balinese_saka_calendar
|
||||
"""
|
||||
|
||||
NYEPI_DATES = {
|
||||
1983: (MAR, 15),
|
||||
1984: (MAR, 4),
|
||||
1985: (MAR, 22),
|
||||
1986: (MAR, 12),
|
||||
1987: (MAR, 31),
|
||||
1988: (MAR, 19),
|
||||
1989: (MAR, 9),
|
||||
1990: (MAR, 27),
|
||||
1991: (MAR, 17),
|
||||
1992: (MAR, 5),
|
||||
1993: (MAR, 24),
|
||||
1994: (MAR, 12),
|
||||
1995: (APR, 1),
|
||||
1996: (MAR, 21),
|
||||
1997: (APR, 9),
|
||||
1998: (MAR, 29),
|
||||
1999: (MAR, 18),
|
||||
2000: (APR, 4),
|
||||
2001: (MAR, 25),
|
||||
2002: (APR, 13),
|
||||
2003: (APR, 2),
|
||||
2004: (MAR, 22),
|
||||
2005: (MAR, 11),
|
||||
2006: (MAR, 30),
|
||||
2007: (MAR, 19),
|
||||
2008: (MAR, 7),
|
||||
2009: (MAR, 26),
|
||||
2010: (MAR, 16),
|
||||
2011: (MAR, 5),
|
||||
2012: (MAR, 23),
|
||||
2013: (MAR, 12),
|
||||
2014: (MAR, 31),
|
||||
2015: (MAR, 21),
|
||||
2016: (MAR, 9),
|
||||
2017: (MAR, 28),
|
||||
2018: (MAR, 17),
|
||||
2019: (MAR, 7),
|
||||
2020: (MAR, 25),
|
||||
2021: (MAR, 14),
|
||||
2022: (MAR, 3),
|
||||
2023: (MAR, 22),
|
||||
2024: (MAR, 11),
|
||||
2025: (MAR, 29),
|
||||
2026: (MAR, 19),
|
||||
2027: (MAR, 8),
|
||||
2028: (MAR, 26),
|
||||
2029: (MAR, 15),
|
||||
2030: (MAR, 5),
|
||||
2031: (MAR, 24),
|
||||
2032: (MAR, 12),
|
||||
2033: (MAR, 31),
|
||||
2034: (MAR, 20),
|
||||
2035: (MAR, 10),
|
||||
2036: (MAR, 28),
|
||||
2037: (MAR, 17),
|
||||
2038: (MAR, 6),
|
||||
2039: (MAR, 25),
|
||||
2040: (MAR, 14),
|
||||
2041: (MAR, 3),
|
||||
2042: (MAR, 22),
|
||||
2043: (MAR, 11),
|
||||
2044: (MAR, 29),
|
||||
2045: (MAR, 19),
|
||||
2046: (MAR, 8),
|
||||
2047: (MAR, 27),
|
||||
2048: (MAR, 15),
|
||||
2049: (MAR, 5),
|
||||
2050: (MAR, 24),
|
||||
}
|
||||
|
||||
def _get_holiday(self, holiday: str, year: int) -> Optional[date]:
|
||||
dt = getattr(self, f"{holiday}_DATES", {}).get(year, ())
|
||||
return date(year, *dt) if dt else None
|
||||
|
||||
def nyepi_date(self, year: int) -> Optional[date]:
|
||||
"""
|
||||
Data References:
|
||||
* [1983-2025](https://id.wikipedia.org/wiki/Indonesia_dalam_tahun_1983)
|
||||
* [2020-2050](https://web.archive.org/web/20240718011857/https://www.balitrips.com/balinese-temples-ceremony)
|
||||
"""
|
||||
return self._get_holiday(NYEPI, year)
|
||||
@ -0,0 +1,444 @@
|
||||
# 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)
|
||||
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from holidays.calendars.custom import _CustomCalendar
|
||||
from holidays.calendars.gregorian import MAY, JUN
|
||||
|
||||
VESAK = "VESAK"
|
||||
VESAK_MAY = "VESAK_MAY"
|
||||
|
||||
|
||||
class _BuddhistLunisolar:
|
||||
VESAK_DATES = {
|
||||
1901: (JUN, 1),
|
||||
1902: (MAY, 22),
|
||||
1903: (MAY, 11),
|
||||
1904: (MAY, 29),
|
||||
1905: (MAY, 18),
|
||||
1906: (MAY, 8),
|
||||
1907: (MAY, 26),
|
||||
1908: (MAY, 14),
|
||||
1909: (JUN, 2),
|
||||
1910: (MAY, 23),
|
||||
1911: (MAY, 13),
|
||||
1912: (MAY, 31),
|
||||
1913: (MAY, 20),
|
||||
1914: (MAY, 9),
|
||||
1915: (MAY, 28),
|
||||
1916: (MAY, 16),
|
||||
1917: (JUN, 4),
|
||||
1918: (MAY, 24),
|
||||
1919: (MAY, 14),
|
||||
1920: (JUN, 1),
|
||||
1921: (MAY, 22),
|
||||
1922: (MAY, 11),
|
||||
1923: (MAY, 30),
|
||||
1924: (MAY, 18),
|
||||
1925: (MAY, 7),
|
||||
1926: (MAY, 26),
|
||||
1927: (MAY, 15),
|
||||
1928: (JUN, 2),
|
||||
1929: (MAY, 23),
|
||||
1930: (MAY, 13),
|
||||
1931: (MAY, 31),
|
||||
1932: (MAY, 20),
|
||||
1933: (MAY, 9),
|
||||
1934: (MAY, 27),
|
||||
1935: (MAY, 17),
|
||||
1936: (JUN, 4),
|
||||
1937: (MAY, 24),
|
||||
1938: (MAY, 14),
|
||||
1939: (JUN, 2),
|
||||
1940: (MAY, 21),
|
||||
1941: (MAY, 10),
|
||||
1942: (MAY, 29),
|
||||
1943: (MAY, 18),
|
||||
1944: (MAY, 7),
|
||||
1945: (MAY, 26),
|
||||
1946: (MAY, 15),
|
||||
1947: (JUN, 3),
|
||||
1948: (MAY, 23),
|
||||
1949: (MAY, 12),
|
||||
1950: (MAY, 31),
|
||||
1951: (MAY, 20),
|
||||
1952: (MAY, 8),
|
||||
1953: (MAY, 27),
|
||||
1954: (MAY, 17),
|
||||
1955: (JUN, 5),
|
||||
1956: (MAY, 24),
|
||||
1957: (MAY, 14),
|
||||
1958: (JUN, 2),
|
||||
1959: (MAY, 22),
|
||||
1960: (MAY, 10),
|
||||
1961: (MAY, 29),
|
||||
1962: (MAY, 18),
|
||||
1963: (MAY, 8),
|
||||
1964: (MAY, 26),
|
||||
1965: (MAY, 15),
|
||||
1966: (JUN, 3),
|
||||
1967: (MAY, 23),
|
||||
1968: (MAY, 11),
|
||||
1969: (MAY, 30),
|
||||
1970: (MAY, 19),
|
||||
1971: (MAY, 9),
|
||||
1972: (MAY, 27),
|
||||
1973: (MAY, 17),
|
||||
1974: (MAY, 6),
|
||||
1975: (MAY, 25),
|
||||
1976: (MAY, 13),
|
||||
1977: (JUN, 1),
|
||||
1978: (MAY, 21),
|
||||
1979: (MAY, 10),
|
||||
1980: (MAY, 28),
|
||||
1981: (MAY, 18),
|
||||
1982: (MAY, 8),
|
||||
1983: (MAY, 27),
|
||||
1984: (MAY, 15),
|
||||
1985: (JUN, 3),
|
||||
1986: (MAY, 23),
|
||||
1987: (MAY, 12),
|
||||
1988: (MAY, 30),
|
||||
1989: (MAY, 19),
|
||||
1990: (MAY, 9),
|
||||
1991: (MAY, 28),
|
||||
1992: (MAY, 17),
|
||||
1993: (JUN, 4),
|
||||
1994: (MAY, 25),
|
||||
1995: (MAY, 14),
|
||||
1996: (MAY, 31),
|
||||
1997: (MAY, 21),
|
||||
1998: (MAY, 10),
|
||||
1999: (MAY, 29),
|
||||
2000: (MAY, 18),
|
||||
2001: (MAY, 7),
|
||||
2002: (MAY, 26),
|
||||
2003: (MAY, 15),
|
||||
2004: (JUN, 2),
|
||||
2005: (MAY, 22),
|
||||
2006: (MAY, 12),
|
||||
2007: (MAY, 31),
|
||||
2008: (MAY, 19),
|
||||
2009: (MAY, 9),
|
||||
2010: (MAY, 28),
|
||||
2011: (MAY, 17),
|
||||
2012: (MAY, 5),
|
||||
2013: (MAY, 24),
|
||||
2014: (MAY, 13),
|
||||
2015: (JUN, 1),
|
||||
2016: (MAY, 21),
|
||||
2017: (MAY, 10),
|
||||
2018: (MAY, 29),
|
||||
2019: (MAY, 19),
|
||||
2020: (MAY, 7),
|
||||
2021: (MAY, 26),
|
||||
2022: (MAY, 15),
|
||||
2023: (JUN, 2),
|
||||
2024: (MAY, 22),
|
||||
2025: (MAY, 12),
|
||||
2026: (MAY, 31),
|
||||
2027: (MAY, 20),
|
||||
2028: (MAY, 9),
|
||||
2029: (MAY, 27),
|
||||
2030: (MAY, 16),
|
||||
2031: (JUN, 4),
|
||||
2032: (MAY, 23),
|
||||
2033: (MAY, 13),
|
||||
2034: (JUN, 1),
|
||||
2035: (MAY, 22),
|
||||
2036: (MAY, 10),
|
||||
2037: (MAY, 29),
|
||||
2038: (MAY, 18),
|
||||
2039: (MAY, 7),
|
||||
2040: (MAY, 25),
|
||||
2041: (MAY, 14),
|
||||
2042: (JUN, 2),
|
||||
2043: (MAY, 23),
|
||||
2044: (MAY, 12),
|
||||
2045: (MAY, 31),
|
||||
2046: (MAY, 20),
|
||||
2047: (MAY, 9),
|
||||
2048: (MAY, 27),
|
||||
2049: (MAY, 16),
|
||||
2050: (JUN, 4),
|
||||
2051: (MAY, 24),
|
||||
2052: (MAY, 13),
|
||||
2053: (JUN, 1),
|
||||
2054: (MAY, 22),
|
||||
2055: (MAY, 11),
|
||||
2056: (MAY, 29),
|
||||
2057: (MAY, 18),
|
||||
2058: (MAY, 7),
|
||||
2059: (MAY, 26),
|
||||
2060: (MAY, 14),
|
||||
2061: (JUN, 2),
|
||||
2062: (MAY, 23),
|
||||
2063: (MAY, 12),
|
||||
2064: (MAY, 30),
|
||||
2065: (MAY, 19),
|
||||
2066: (MAY, 8),
|
||||
2067: (MAY, 27),
|
||||
2068: (MAY, 16),
|
||||
2069: (MAY, 5),
|
||||
2070: (MAY, 24),
|
||||
2071: (MAY, 14),
|
||||
2072: (JUN, 1),
|
||||
2073: (MAY, 21),
|
||||
2074: (MAY, 10),
|
||||
2075: (MAY, 29),
|
||||
2076: (MAY, 17),
|
||||
2077: (MAY, 7),
|
||||
2078: (MAY, 26),
|
||||
2079: (MAY, 15),
|
||||
2080: (JUN, 2),
|
||||
2081: (MAY, 23),
|
||||
2082: (MAY, 12),
|
||||
2083: (MAY, 31),
|
||||
2084: (MAY, 19),
|
||||
2085: (MAY, 8),
|
||||
2086: (MAY, 27),
|
||||
2087: (MAY, 17),
|
||||
2088: (MAY, 5),
|
||||
2089: (MAY, 24),
|
||||
2090: (MAY, 14),
|
||||
2091: (JUN, 1),
|
||||
2092: (MAY, 20),
|
||||
2093: (MAY, 10),
|
||||
2094: (MAY, 28),
|
||||
2095: (MAY, 18),
|
||||
2096: (MAY, 7),
|
||||
2097: (MAY, 26),
|
||||
2098: (MAY, 15),
|
||||
2099: (JUN, 3),
|
||||
2100: (MAY, 23),
|
||||
}
|
||||
|
||||
VESAK_MAY_DATES = {
|
||||
1901: (MAY, 3),
|
||||
1902: (MAY, 22),
|
||||
1903: (MAY, 11),
|
||||
1904: (MAY, 29),
|
||||
1905: (MAY, 18),
|
||||
1906: (MAY, 8),
|
||||
1907: (MAY, 26),
|
||||
1908: (MAY, 14),
|
||||
1909: (MAY, 4),
|
||||
1910: (MAY, 23),
|
||||
1911: (MAY, 13),
|
||||
1912: (MAY, 1),
|
||||
1913: (MAY, 20),
|
||||
1914: (MAY, 9),
|
||||
1915: (MAY, 28),
|
||||
1916: (MAY, 16),
|
||||
1917: (MAY, 5),
|
||||
1918: (MAY, 24),
|
||||
1919: (MAY, 14),
|
||||
1920: (MAY, 3),
|
||||
1921: (MAY, 22),
|
||||
1922: (MAY, 11),
|
||||
1923: (MAY, 30),
|
||||
1924: (MAY, 18),
|
||||
1925: (MAY, 7),
|
||||
1926: (MAY, 26),
|
||||
1927: (MAY, 15),
|
||||
1928: (MAY, 4),
|
||||
1929: (MAY, 23),
|
||||
1930: (MAY, 13),
|
||||
1931: (MAY, 2),
|
||||
1932: (MAY, 20),
|
||||
1933: (MAY, 9),
|
||||
1934: (MAY, 27),
|
||||
1935: (MAY, 17),
|
||||
1936: (MAY, 5),
|
||||
1937: (MAY, 24),
|
||||
1938: (MAY, 14),
|
||||
1939: (MAY, 4),
|
||||
1940: (MAY, 21),
|
||||
1941: (MAY, 10),
|
||||
1942: (MAY, 29),
|
||||
1943: (MAY, 18),
|
||||
1944: (MAY, 7),
|
||||
1945: (MAY, 26),
|
||||
1946: (MAY, 15),
|
||||
1947: (MAY, 5),
|
||||
1948: (MAY, 23),
|
||||
1949: (MAY, 12),
|
||||
1950: (MAY, 1),
|
||||
1951: (MAY, 20),
|
||||
1952: (MAY, 8),
|
||||
1953: (MAY, 27),
|
||||
1954: (MAY, 17),
|
||||
1955: (MAY, 6),
|
||||
1956: (MAY, 24),
|
||||
1957: (MAY, 14),
|
||||
1958: (MAY, 3),
|
||||
1959: (MAY, 22),
|
||||
1960: (MAY, 10),
|
||||
1961: (MAY, 29),
|
||||
1962: (MAY, 18),
|
||||
1963: (MAY, 8),
|
||||
1964: (MAY, 26),
|
||||
1965: (MAY, 15),
|
||||
1966: (MAY, 5),
|
||||
1967: (MAY, 23),
|
||||
1968: (MAY, 11),
|
||||
1969: (MAY, 1),
|
||||
1970: (MAY, 19),
|
||||
1971: (MAY, 9),
|
||||
1972: (MAY, 27),
|
||||
1973: (MAY, 17),
|
||||
1974: (MAY, 6),
|
||||
1975: (MAY, 25),
|
||||
1976: (MAY, 13),
|
||||
1977: (MAY, 2),
|
||||
1978: (MAY, 21),
|
||||
1979: (MAY, 10),
|
||||
1980: (MAY, 28),
|
||||
1981: (MAY, 18),
|
||||
1982: (MAY, 8),
|
||||
1983: (MAY, 27),
|
||||
1984: (MAY, 15),
|
||||
1985: (MAY, 4),
|
||||
1986: (MAY, 23),
|
||||
1987: (MAY, 12),
|
||||
1988: (MAY, 30),
|
||||
1989: (MAY, 19),
|
||||
1990: (MAY, 9),
|
||||
1991: (MAY, 28),
|
||||
1992: (MAY, 17),
|
||||
1993: (MAY, 6),
|
||||
1994: (MAY, 25),
|
||||
1995: (MAY, 14),
|
||||
1996: (MAY, 2),
|
||||
1997: (MAY, 21),
|
||||
1998: (MAY, 10),
|
||||
1999: (MAY, 29),
|
||||
2000: (MAY, 18),
|
||||
2001: (MAY, 7),
|
||||
2002: (MAY, 26),
|
||||
2003: (MAY, 15),
|
||||
2004: (MAY, 3),
|
||||
2005: (MAY, 22),
|
||||
2006: (MAY, 12),
|
||||
2007: (MAY, 1),
|
||||
2008: (MAY, 19),
|
||||
2009: (MAY, 9),
|
||||
2010: (MAY, 28),
|
||||
2011: (MAY, 17),
|
||||
2012: (MAY, 5),
|
||||
2013: (MAY, 24),
|
||||
2014: (MAY, 13),
|
||||
2015: (MAY, 3),
|
||||
2016: (MAY, 21),
|
||||
2017: (MAY, 10),
|
||||
2018: (MAY, 29),
|
||||
2019: (MAY, 19),
|
||||
2020: (MAY, 7),
|
||||
2021: (MAY, 26),
|
||||
2022: (MAY, 15),
|
||||
2023: (MAY, 4),
|
||||
2024: (MAY, 22),
|
||||
2025: (MAY, 12),
|
||||
2026: (MAY, 1),
|
||||
2027: (MAY, 20),
|
||||
2028: (MAY, 9),
|
||||
2029: (MAY, 27),
|
||||
2030: (MAY, 16),
|
||||
2031: (MAY, 6),
|
||||
2032: (MAY, 23),
|
||||
2033: (MAY, 13),
|
||||
2034: (MAY, 3),
|
||||
2035: (MAY, 22),
|
||||
2036: (MAY, 10),
|
||||
2037: (MAY, 29),
|
||||
2038: (MAY, 18),
|
||||
2039: (MAY, 7),
|
||||
2040: (MAY, 25),
|
||||
2041: (MAY, 14),
|
||||
2042: (MAY, 4),
|
||||
2043: (MAY, 23),
|
||||
2044: (MAY, 12),
|
||||
2045: (MAY, 1),
|
||||
2046: (MAY, 20),
|
||||
2047: (MAY, 9),
|
||||
2048: (MAY, 27),
|
||||
2049: (MAY, 16),
|
||||
2050: (MAY, 5),
|
||||
2051: (MAY, 24),
|
||||
2052: (MAY, 13),
|
||||
2053: (MAY, 3),
|
||||
2054: (MAY, 22),
|
||||
2055: (MAY, 11),
|
||||
2056: (MAY, 29),
|
||||
2057: (MAY, 18),
|
||||
2058: (MAY, 7),
|
||||
2059: (MAY, 26),
|
||||
2060: (MAY, 14),
|
||||
2061: (MAY, 4),
|
||||
2062: (MAY, 23),
|
||||
2063: (MAY, 12),
|
||||
2064: (MAY, 1),
|
||||
2065: (MAY, 19),
|
||||
2066: (MAY, 8),
|
||||
2067: (MAY, 27),
|
||||
2068: (MAY, 16),
|
||||
2069: (MAY, 5),
|
||||
2070: (MAY, 24),
|
||||
2071: (MAY, 14),
|
||||
2072: (MAY, 2),
|
||||
2073: (MAY, 21),
|
||||
2074: (MAY, 10),
|
||||
2075: (MAY, 29),
|
||||
2076: (MAY, 17),
|
||||
2077: (MAY, 7),
|
||||
2078: (MAY, 26),
|
||||
2079: (MAY, 15),
|
||||
2080: (MAY, 4),
|
||||
2081: (MAY, 23),
|
||||
2082: (MAY, 12),
|
||||
2083: (MAY, 1),
|
||||
2084: (MAY, 19),
|
||||
2085: (MAY, 8),
|
||||
2086: (MAY, 27),
|
||||
2087: (MAY, 17),
|
||||
2088: (MAY, 5),
|
||||
2089: (MAY, 24),
|
||||
2090: (MAY, 14),
|
||||
2091: (MAY, 3),
|
||||
2092: (MAY, 20),
|
||||
2093: (MAY, 10),
|
||||
2094: (MAY, 28),
|
||||
2095: (MAY, 18),
|
||||
2096: (MAY, 7),
|
||||
2097: (MAY, 26),
|
||||
2098: (MAY, 15),
|
||||
2099: (MAY, 4),
|
||||
2100: (MAY, 23),
|
||||
}
|
||||
|
||||
def _get_holiday(self, holiday: str, year: int) -> tuple[Optional[date], bool]:
|
||||
estimated_dates = getattr(self, f"{holiday}_DATES", {})
|
||||
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
|
||||
dt = exact_dates.get(year, estimated_dates.get(year, ()))
|
||||
return date(year, *dt) if dt else None, year not in exact_dates
|
||||
|
||||
def vesak_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(VESAK, year)
|
||||
|
||||
def vesak_may_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(VESAK_MAY, year)
|
||||
|
||||
|
||||
class _CustomBuddhistHolidays(_CustomCalendar, _BuddhistLunisolar):
|
||||
pass
|
||||
1354
.venv/lib/python3.12/site-packages/holidays/calendars/chinese.py
Normal file
1354
.venv/lib/python3.12/site-packages/holidays/calendars/chinese.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,34 @@
|
||||
# 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)
|
||||
|
||||
|
||||
class _CustomCalendarType(type):
|
||||
"""Helper class for simple calendar customization.
|
||||
|
||||
Renames child class public attributes keeping the original data under a new
|
||||
name with a `CUSTOM_ATTR_POSTFIX` postfix.
|
||||
|
||||
Allows for better readability of customized lunisolar calendar dates.
|
||||
"""
|
||||
|
||||
CUSTOM_ATTR_POSTFIX = "CUSTOM_CALENDAR"
|
||||
|
||||
def __new__(cls, name, bases, namespace):
|
||||
for attr in (key for key in tuple(namespace.keys()) if key[0] != "_"):
|
||||
namespace[f"{attr}_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}"] = namespace[attr]
|
||||
del namespace[attr]
|
||||
|
||||
return super().__new__(cls, name, bases, namespace)
|
||||
|
||||
|
||||
class _CustomCalendar(metaclass=_CustomCalendarType):
|
||||
pass
|
||||
@ -0,0 +1,95 @@
|
||||
# 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)
|
||||
|
||||
from datetime import date
|
||||
|
||||
GREGORIAN_CALENDAR = "GREGORIAN_CALENDAR"
|
||||
|
||||
MON, TUE, WED, THU, FRI, SAT, SUN = range(7)
|
||||
WEEKEND = (SAT, SUN)
|
||||
|
||||
JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC = range(1, 13)
|
||||
|
||||
DAYS = {str(d) for d in range(1, 32)}
|
||||
MONTHS = {
|
||||
m: i
|
||||
for i, m in enumerate(
|
||||
("jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"), 1
|
||||
)
|
||||
}
|
||||
WEEKDAYS = {w: i for i, w in enumerate(("mon", "tue", "wed", "thu", "fri", "sat", "sun"))}
|
||||
|
||||
|
||||
# Holiday names.
|
||||
CHRISTMAS = "christmas"
|
||||
WINTER_SOLSTICE = "winter_solstice"
|
||||
|
||||
|
||||
def _timedelta(dt: date, days: int = 0) -> date:
|
||||
"""
|
||||
Return date that is `days` days after (days > 0) or before (days < 0) specified date.
|
||||
"""
|
||||
|
||||
return date.fromordinal(dt.toordinal() + days)
|
||||
|
||||
|
||||
def _get_nth_weekday_from(n: int, weekday: int, from_dt: date) -> date:
|
||||
"""
|
||||
Return date of a n-th weekday before a specific date
|
||||
if n is negative.
|
||||
Return date of n-th weekday after (including) a specific date
|
||||
if n is positive.
|
||||
Examples: 1st Monday, 2nd Saturday, etc).
|
||||
"""
|
||||
|
||||
return _timedelta(
|
||||
from_dt,
|
||||
(
|
||||
(n - 1) * 7 + (weekday - from_dt.weekday()) % 7
|
||||
if n > 0
|
||||
else (n + 1) * 7 - (from_dt.weekday() - weekday) % 7
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def _get_nth_weekday_of_month(n: int, weekday: int, month: int, year: int) -> date:
|
||||
"""
|
||||
Return date of n-th weekday of month for a specific year
|
||||
(e.g. 1st Monday of Apr, 2nd Friday of June, etc).
|
||||
If n is negative the countdown starts at the end of month
|
||||
(i.e. -1 is last).
|
||||
"""
|
||||
|
||||
requested_year_month = (year, month)
|
||||
|
||||
if n < 0:
|
||||
month += 1
|
||||
if month > 12:
|
||||
month = 1
|
||||
year += 1
|
||||
start_date = _timedelta(date(year, month, 1), -1)
|
||||
else:
|
||||
start_date = date(year, month, 1)
|
||||
|
||||
dt = _get_nth_weekday_from(n, weekday, start_date)
|
||||
dt_year_month = (dt.year, dt.month)
|
||||
|
||||
if dt_year_month != requested_year_month:
|
||||
raise ValueError(f"{dt_year_month} returned for {requested_year_month}")
|
||||
|
||||
return dt
|
||||
|
||||
|
||||
def _get_all_sundays(year):
|
||||
first_sunday = _get_nth_weekday_of_month(1, SUN, JAN, year)
|
||||
for n in range(0, (date(year, DEC, 31) - first_sunday).days + 1, 7):
|
||||
yield _timedelta(first_sunday, n)
|
||||
1633
.venv/lib/python3.12/site-packages/holidays/calendars/hebrew.py
Normal file
1633
.venv/lib/python3.12/site-packages/holidays/calendars/hebrew.py
Normal file
File diff suppressed because it is too large
Load Diff
1494
.venv/lib/python3.12/site-packages/holidays/calendars/hindu.py
Normal file
1494
.venv/lib/python3.12/site-packages/holidays/calendars/hindu.py
Normal file
File diff suppressed because it is too large
Load Diff
4043
.venv/lib/python3.12/site-packages/holidays/calendars/islamic.py
Normal file
4043
.venv/lib/python3.12/site-packages/holidays/calendars/islamic.py
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
||||
# 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)
|
||||
|
||||
JULIAN_CALENDAR = "JULIAN_CALENDAR"
|
||||
@ -0,0 +1,13 @@
|
||||
# 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)
|
||||
|
||||
JULIAN_REVISED_CALENDAR = "JULIAN_REVISED_CALENDAR"
|
||||
@ -0,0 +1,342 @@
|
||||
# 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)
|
||||
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from holidays.calendars.custom import _CustomCalendar
|
||||
from holidays.calendars.gregorian import JAN, FEB, MAR, MAY, JUN, OCT, NOV, DEC
|
||||
|
||||
BUDDHA_DAY = "BUDDHA_DAY"
|
||||
GENGHIS_KHAN_DAY = "GENGHIS_KHAN_DAY"
|
||||
TSAGAAN_SAR = "TSAGAAN_SAR"
|
||||
|
||||
|
||||
class _MongolianLunisolar:
|
||||
BUDDHA_DAY_DATES = {
|
||||
2004: (JUN, 3),
|
||||
2005: (MAY, 23),
|
||||
2006: (JUN, 11),
|
||||
2007: (MAY, 31),
|
||||
2008: (MAY, 20),
|
||||
2009: (JUN, 7),
|
||||
2010: (MAY, 27),
|
||||
2011: (MAY, 17),
|
||||
2012: (JUN, 4),
|
||||
2013: (MAY, 25),
|
||||
2014: (JUN, 13),
|
||||
2015: (JUN, 2),
|
||||
2016: (MAY, 21),
|
||||
2017: (JUN, 9),
|
||||
2018: (MAY, 29),
|
||||
2019: (MAY, 18),
|
||||
2020: (JUN, 5),
|
||||
2021: (MAY, 26),
|
||||
2022: (JUN, 14),
|
||||
2023: (JUN, 4),
|
||||
2024: (MAY, 23),
|
||||
2025: (JUN, 11),
|
||||
2026: (MAY, 31),
|
||||
2027: (MAY, 20),
|
||||
2028: (JUN, 7),
|
||||
2029: (MAY, 27),
|
||||
2030: (MAY, 17),
|
||||
2031: (JUN, 5),
|
||||
2032: (MAY, 25),
|
||||
2033: (JUN, 12),
|
||||
2034: (JUN, 2),
|
||||
2035: (MAY, 22),
|
||||
2036: (JUN, 8),
|
||||
2037: (MAY, 29),
|
||||
2038: (MAY, 18),
|
||||
2039: (JUN, 6),
|
||||
2040: (MAY, 26),
|
||||
2041: (JUN, 14),
|
||||
2042: (JUN, 3),
|
||||
2043: (MAY, 23),
|
||||
2044: (JUN, 10),
|
||||
2045: (MAY, 30),
|
||||
2046: (MAY, 20),
|
||||
2047: (JUN, 8),
|
||||
2048: (MAY, 27),
|
||||
2049: (MAY, 17),
|
||||
2050: (JUN, 5),
|
||||
2051: (MAY, 25),
|
||||
2052: (JUN, 12),
|
||||
2053: (JUN, 1),
|
||||
2054: (MAY, 21),
|
||||
2055: (JUN, 9),
|
||||
2056: (MAY, 29),
|
||||
2057: (MAY, 18),
|
||||
2058: (JUN, 6),
|
||||
2059: (MAY, 27),
|
||||
2060: (JUN, 14),
|
||||
2061: (JUN, 3),
|
||||
2062: (MAY, 23),
|
||||
2063: (JUN, 11),
|
||||
2064: (MAY, 30),
|
||||
2065: (MAY, 20),
|
||||
2066: (JUN, 8),
|
||||
2067: (MAY, 28),
|
||||
2068: (JUN, 15),
|
||||
2069: (JUN, 4),
|
||||
2070: (MAY, 24),
|
||||
2071: (JUN, 12),
|
||||
2072: (MAY, 31),
|
||||
2073: (MAY, 21),
|
||||
2074: (JUN, 9),
|
||||
2075: (MAY, 30),
|
||||
2076: (MAY, 18),
|
||||
2077: (JUN, 6),
|
||||
2078: (MAY, 26),
|
||||
2079: (JUN, 14),
|
||||
2080: (JUN, 2),
|
||||
2081: (MAY, 22),
|
||||
2082: (JUN, 10),
|
||||
2083: (MAY, 31),
|
||||
2084: (MAY, 20),
|
||||
2085: (JUN, 8),
|
||||
2086: (MAY, 28),
|
||||
2087: (JUN, 16),
|
||||
2088: (JUN, 4),
|
||||
2089: (MAY, 24),
|
||||
2090: (JUN, 12),
|
||||
2091: (JUN, 1),
|
||||
2092: (MAY, 21),
|
||||
2093: (JUN, 9),
|
||||
2094: (MAY, 30),
|
||||
2095: (MAY, 19),
|
||||
2096: (JUN, 6),
|
||||
2097: (MAY, 26),
|
||||
2098: (JUN, 13),
|
||||
2099: (JUN, 3),
|
||||
2100: (MAY, 23),
|
||||
}
|
||||
|
||||
GENGHIS_KHAN_DAY_DATES = {
|
||||
2004: (NOV, 13),
|
||||
2005: (NOV, 2),
|
||||
2006: (NOV, 21),
|
||||
2007: (NOV, 10),
|
||||
2008: (NOV, 28),
|
||||
2009: (NOV, 17),
|
||||
2010: (NOV, 7),
|
||||
2011: (NOV, 26),
|
||||
2012: (NOV, 14),
|
||||
2013: (NOV, 4),
|
||||
2014: (NOV, 23),
|
||||
2015: (NOV, 12),
|
||||
2016: (OCT, 31),
|
||||
2017: (NOV, 19),
|
||||
2018: (NOV, 8),
|
||||
2019: (NOV, 27),
|
||||
2020: (NOV, 16),
|
||||
2021: (NOV, 5),
|
||||
2022: (NOV, 24),
|
||||
2023: (NOV, 14),
|
||||
2024: (NOV, 2),
|
||||
2025: (NOV, 21),
|
||||
2026: (NOV, 10),
|
||||
2027: (NOV, 29),
|
||||
2028: (NOV, 17),
|
||||
2029: (NOV, 7),
|
||||
2030: (NOV, 26),
|
||||
2031: (NOV, 15),
|
||||
2032: (NOV, 4),
|
||||
2033: (NOV, 22),
|
||||
2034: (NOV, 11),
|
||||
2035: (NOV, 30),
|
||||
2036: (NOV, 18),
|
||||
2037: (NOV, 8),
|
||||
2038: (NOV, 27),
|
||||
2039: (NOV, 17),
|
||||
2040: (NOV, 5),
|
||||
2041: (NOV, 24),
|
||||
2042: (NOV, 13),
|
||||
2043: (NOV, 2),
|
||||
2044: (NOV, 20),
|
||||
2045: (NOV, 9),
|
||||
2046: (NOV, 28),
|
||||
2047: (NOV, 18),
|
||||
2048: (NOV, 7),
|
||||
2049: (NOV, 26),
|
||||
2050: (NOV, 15),
|
||||
2051: (NOV, 4),
|
||||
2052: (NOV, 22),
|
||||
2053: (NOV, 11),
|
||||
2054: (NOV, 30),
|
||||
2055: (NOV, 19),
|
||||
2056: (NOV, 8),
|
||||
2057: (NOV, 27),
|
||||
2058: (NOV, 17),
|
||||
2059: (NOV, 6),
|
||||
2060: (NOV, 24),
|
||||
2061: (NOV, 13),
|
||||
2062: (NOV, 2),
|
||||
2063: (NOV, 21),
|
||||
2064: (NOV, 9),
|
||||
2065: (NOV, 28),
|
||||
2066: (NOV, 18),
|
||||
2067: (NOV, 7),
|
||||
2068: (NOV, 25),
|
||||
2069: (NOV, 14),
|
||||
2070: (NOV, 3),
|
||||
2071: (NOV, 22),
|
||||
2072: (NOV, 11),
|
||||
2073: (NOV, 30),
|
||||
2074: (NOV, 19),
|
||||
2075: (NOV, 9),
|
||||
2076: (NOV, 27),
|
||||
2077: (NOV, 16),
|
||||
2078: (NOV, 5),
|
||||
2079: (NOV, 24),
|
||||
2080: (NOV, 12),
|
||||
2081: (NOV, 1),
|
||||
2082: (NOV, 21),
|
||||
2083: (NOV, 10),
|
||||
2084: (NOV, 28),
|
||||
2085: (NOV, 18),
|
||||
2086: (NOV, 7),
|
||||
2087: (NOV, 26),
|
||||
2088: (NOV, 14),
|
||||
2089: (NOV, 3),
|
||||
2090: (NOV, 22),
|
||||
2091: (NOV, 12),
|
||||
2092: (NOV, 30),
|
||||
2093: (NOV, 19),
|
||||
2094: (NOV, 9),
|
||||
2095: (NOV, 27),
|
||||
2096: (NOV, 15),
|
||||
2097: (NOV, 5),
|
||||
2098: (NOV, 23),
|
||||
2099: (NOV, 13),
|
||||
2100: (DEC, 2),
|
||||
}
|
||||
|
||||
TSAGAAN_SAR_DATES = {
|
||||
2004: (FEB, 21),
|
||||
2005: (FEB, 9),
|
||||
2006: (JAN, 30),
|
||||
2007: (FEB, 18),
|
||||
2008: (FEB, 8),
|
||||
2009: (FEB, 25),
|
||||
2010: (FEB, 14),
|
||||
2011: (FEB, 3),
|
||||
2012: (FEB, 22),
|
||||
2013: (FEB, 11),
|
||||
2014: (JAN, 31),
|
||||
2015: (FEB, 19),
|
||||
2016: (FEB, 9),
|
||||
2017: (FEB, 27),
|
||||
2018: (FEB, 16),
|
||||
2019: (FEB, 5),
|
||||
2020: (FEB, 24),
|
||||
2021: (FEB, 12),
|
||||
2022: (FEB, 2),
|
||||
2023: (FEB, 21),
|
||||
2024: (FEB, 10),
|
||||
2025: (MAR, 1),
|
||||
2026: (FEB, 18),
|
||||
2027: (FEB, 7),
|
||||
2028: (FEB, 26),
|
||||
2029: (FEB, 14),
|
||||
2030: (FEB, 3),
|
||||
2031: (FEB, 22),
|
||||
2032: (FEB, 12),
|
||||
2033: (JAN, 31),
|
||||
2034: (FEB, 19),
|
||||
2035: (FEB, 9),
|
||||
2036: (FEB, 28),
|
||||
2037: (FEB, 16),
|
||||
2038: (FEB, 5),
|
||||
2039: (FEB, 24),
|
||||
2040: (FEB, 13),
|
||||
2041: (FEB, 2),
|
||||
2042: (FEB, 21),
|
||||
2043: (FEB, 10),
|
||||
2044: (FEB, 29),
|
||||
2045: (FEB, 17),
|
||||
2046: (FEB, 6),
|
||||
2047: (FEB, 25),
|
||||
2048: (FEB, 14),
|
||||
2049: (FEB, 3),
|
||||
2050: (FEB, 22),
|
||||
2051: (FEB, 12),
|
||||
2052: (FEB, 1),
|
||||
2053: (FEB, 19),
|
||||
2054: (FEB, 8),
|
||||
2055: (FEB, 27),
|
||||
2056: (FEB, 16),
|
||||
2057: (FEB, 4),
|
||||
2058: (FEB, 23),
|
||||
2059: (FEB, 13),
|
||||
2060: (FEB, 3),
|
||||
2061: (FEB, 21),
|
||||
2062: (FEB, 10),
|
||||
2063: (MAR, 1),
|
||||
2064: (FEB, 18),
|
||||
2065: (FEB, 6),
|
||||
2066: (FEB, 25),
|
||||
2067: (FEB, 14),
|
||||
2068: (FEB, 4),
|
||||
2069: (FEB, 22),
|
||||
2070: (FEB, 12),
|
||||
2071: (FEB, 1),
|
||||
2072: (FEB, 19),
|
||||
2073: (FEB, 7),
|
||||
2074: (FEB, 26),
|
||||
2075: (FEB, 16),
|
||||
2076: (FEB, 5),
|
||||
2077: (FEB, 23),
|
||||
2078: (FEB, 13),
|
||||
2079: (FEB, 2),
|
||||
2080: (FEB, 21),
|
||||
2081: (FEB, 9),
|
||||
2082: (FEB, 28),
|
||||
2083: (FEB, 17),
|
||||
2084: (FEB, 7),
|
||||
2085: (FEB, 25),
|
||||
2086: (FEB, 14),
|
||||
2087: (FEB, 4),
|
||||
2088: (FEB, 23),
|
||||
2089: (FEB, 11),
|
||||
2090: (MAR, 2),
|
||||
2091: (FEB, 19),
|
||||
2092: (FEB, 8),
|
||||
2093: (FEB, 26),
|
||||
2094: (FEB, 16),
|
||||
2095: (FEB, 5),
|
||||
2096: (FEB, 24),
|
||||
2097: (FEB, 13),
|
||||
2098: (FEB, 2),
|
||||
2099: (FEB, 21),
|
||||
2100: (FEB, 10),
|
||||
}
|
||||
|
||||
def _get_holiday(self, holiday: str, year: int) -> tuple[Optional[date], bool]:
|
||||
estimated_dates = getattr(self, f"{holiday}_DATES", {})
|
||||
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
|
||||
dt = exact_dates.get(year, estimated_dates.get(year, ()))
|
||||
return date(year, *dt) if dt else None, year not in exact_dates
|
||||
|
||||
def buddha_day_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(BUDDHA_DAY, year)
|
||||
|
||||
def genghis_khan_day_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(GENGHIS_KHAN_DAY, year)
|
||||
|
||||
def tsagaan_sar_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(TSAGAAN_SAR, year)
|
||||
|
||||
|
||||
class _CustomMongolianHolidays(_CustomCalendar, _MongolianLunisolar):
|
||||
pass
|
||||
@ -0,0 +1,64 @@
|
||||
# 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)
|
||||
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from holidays.calendars.gregorian import _timedelta
|
||||
|
||||
|
||||
class _Persian:
|
||||
"""
|
||||
Persian calendar (Solar Hijri) for 1901-2100 years.
|
||||
|
||||
https://en.wikipedia.org/wiki/Solar_Hijri_calendar
|
||||
"""
|
||||
|
||||
START_YEAR = 1901
|
||||
END_YEAR = 2100
|
||||
|
||||
def is_leap_year(self, year: int) -> bool:
|
||||
"""
|
||||
Is Persian year that begins in the specified Gregorian year a leap year.
|
||||
"""
|
||||
return (year % 33) in {3, 7, 11, 16, 20, 24, 28, 32}
|
||||
|
||||
def new_year_date(self, year: int) -> Optional[date]:
|
||||
"""
|
||||
Return Gregorian date of Persian new year (1 Farvardin) in a given Gregorian year.
|
||||
"""
|
||||
if year < _Persian.START_YEAR or year > _Persian.END_YEAR:
|
||||
return None
|
||||
|
||||
day = 21
|
||||
if (
|
||||
(year % 4 == 1 and year >= 2029)
|
||||
or (year % 4 == 2 and year >= 2062)
|
||||
or (year % 4 == 3 and year >= 2095)
|
||||
or (year % 4 == 0 and 1996 <= year <= 2096)
|
||||
):
|
||||
day = 20
|
||||
elif (year % 4 == 2 and year <= 1926) or (year % 4 == 3 and year <= 1959):
|
||||
day = 22
|
||||
return date(year, 3, day)
|
||||
|
||||
def persian_to_gregorian(self, year: int, j_month: int, j_day: int) -> Optional[date]:
|
||||
"""
|
||||
Return Gregorian date of Persian day and month in a given Gregorian year.
|
||||
"""
|
||||
start_date = self.new_year_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
m = j_month - 1
|
||||
delta = (31 * m if m < 6 else 186 + 30 * (m - 6)) + j_day - 1
|
||||
return _timedelta(start_date, delta)
|
||||
414
.venv/lib/python3.12/site-packages/holidays/calendars/sinhala.py
Normal file
414
.venv/lib/python3.12/site-packages/holidays/calendars/sinhala.py
Normal file
@ -0,0 +1,414 @@
|
||||
# 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)
|
||||
|
||||
from collections.abc import Iterable
|
||||
from datetime import date
|
||||
from typing import Optional
|
||||
|
||||
from holidays.calendars.custom import _CustomCalendar
|
||||
from holidays.calendars.gregorian import JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC
|
||||
from holidays.helpers import _normalize_tuple
|
||||
|
||||
BAK_POYA = "BAK_POYA"
|
||||
BINARA_POYA = "BINARA_POYA"
|
||||
DURUTHU_POYA = "DURUTHU_POYA"
|
||||
ESALA_POYA = "ESALA_POYA"
|
||||
IL_POYA = "IL_POYA"
|
||||
MEDIN_POYA = "MEDIN_POYA"
|
||||
NAWAM_POYA = "NAWAM_POYA"
|
||||
NIKINI_POYA = "NIKINI_POYA"
|
||||
POSON_POYA = "POSON_POYA"
|
||||
UNDUVAP_POYA = "UNDUVAP_POYA"
|
||||
VAP_POYA = "VAP_POYA"
|
||||
VESAK_POYA = "VESAK_POYA"
|
||||
|
||||
|
||||
class _SinhalaLunar:
|
||||
"""
|
||||
Sinhala Lunar calendar for 2003-2025 years.
|
||||
|
||||
Their Buddhist Uposatha day calculation method is different from Thai LuniSolar
|
||||
and Buddhist (Mahayana) used in East Asia.
|
||||
|
||||
Due to the fact that Poya (Uposatha) days are calculated astronomically
|
||||
based on how close a particular day is closest to full moon at noon, and that
|
||||
an extra month is added every 33 months interval, this is hardcoded for now.
|
||||
|
||||
Adhi month dates are instead hardcoded in Sri Lanka country implementation.
|
||||
"""
|
||||
|
||||
START_YEAR = 2003
|
||||
END_YEAR = 2025
|
||||
|
||||
BAK_POYA_DATES = {
|
||||
2003: (APR, 16),
|
||||
2004: (APR, 5),
|
||||
2005: (APR, 23),
|
||||
2006: (APR, 13),
|
||||
2007: (APR, 2),
|
||||
2008: (APR, 19),
|
||||
2009: (APR, 9),
|
||||
2010: (MAR, 29),
|
||||
2011: (APR, 17),
|
||||
2012: (APR, 6),
|
||||
2013: (APR, 25),
|
||||
2014: (APR, 14),
|
||||
2015: (APR, 3),
|
||||
2016: (APR, 21),
|
||||
2017: (APR, 10),
|
||||
2018: (MAR, 31),
|
||||
2019: (APR, 19),
|
||||
2020: (APR, 7),
|
||||
2021: (APR, 26),
|
||||
2022: (APR, 16),
|
||||
2023: (APR, 5),
|
||||
2024: (APR, 23),
|
||||
2025: (APR, 12),
|
||||
}
|
||||
|
||||
BINARA_POYA_DATES = {
|
||||
2003: (SEP, 10),
|
||||
2004: (SEP, 28),
|
||||
2005: (SEP, 17),
|
||||
2006: (SEP, 7),
|
||||
2007: (SEP, 26),
|
||||
2008: (SEP, 14),
|
||||
2009: (SEP, 4),
|
||||
2010: (SEP, 22),
|
||||
2011: (SEP, 11),
|
||||
2012: (SEP, 29),
|
||||
2013: (SEP, 19),
|
||||
2014: (SEP, 8),
|
||||
2015: (SEP, 27),
|
||||
2016: (SEP, 16),
|
||||
2017: (SEP, 5),
|
||||
2018: (SEP, 24),
|
||||
2019: (SEP, 13),
|
||||
2020: (SEP, 1),
|
||||
2021: (SEP, 20),
|
||||
2022: (SEP, 10),
|
||||
2023: (SEP, 29),
|
||||
2024: (SEP, 17),
|
||||
2025: (SEP, 7),
|
||||
}
|
||||
|
||||
DURUTHU_POYA_DATES = {
|
||||
2003: (JAN, 17),
|
||||
2004: (JAN, 7),
|
||||
2005: (JAN, 24),
|
||||
2006: (JAN, 13),
|
||||
2007: (JAN, 3),
|
||||
2008: (JAN, 22),
|
||||
2009: ((JAN, 10), (DEC, 31)),
|
||||
2011: (JAN, 19),
|
||||
2012: (JAN, 8),
|
||||
2013: (JAN, 26),
|
||||
2014: (JAN, 15),
|
||||
2015: (JAN, 4),
|
||||
2016: (JAN, 23),
|
||||
2017: (JAN, 12),
|
||||
2018: (JAN, 1),
|
||||
2019: (JAN, 20),
|
||||
2020: (JAN, 10),
|
||||
2021: (JAN, 28),
|
||||
2022: (JAN, 17),
|
||||
2023: (JAN, 6),
|
||||
2024: (JAN, 25),
|
||||
2025: (JAN, 13),
|
||||
}
|
||||
|
||||
ESALA_POYA_DATES = {
|
||||
2003: (JUL, 13),
|
||||
2004: (JUL, 2),
|
||||
2005: (JUL, 21),
|
||||
2006: (JUL, 10),
|
||||
2007: (JUL, 29),
|
||||
2008: (JUL, 17),
|
||||
2009: (JUL, 6),
|
||||
2010: (JUL, 25),
|
||||
2011: (JUL, 14),
|
||||
2012: (JUL, 3),
|
||||
2013: (JUL, 22),
|
||||
2014: (JUL, 12),
|
||||
2015: (JUL, 31),
|
||||
2016: (JUL, 19),
|
||||
2017: (JUL, 8),
|
||||
2018: (JUL, 27),
|
||||
2019: (JUL, 16),
|
||||
2020: (JUL, 4),
|
||||
2021: (JUL, 23),
|
||||
2022: (JUL, 13),
|
||||
2023: (AUG, 1),
|
||||
2024: (JUL, 20),
|
||||
2025: (JUL, 10),
|
||||
}
|
||||
|
||||
IL_POYA_DATES = {
|
||||
2003: (NOV, 8),
|
||||
2004: (NOV, 26),
|
||||
2005: (NOV, 15),
|
||||
2006: (NOV, 5),
|
||||
2007: (NOV, 24),
|
||||
2008: (NOV, 12),
|
||||
2009: (NOV, 2),
|
||||
2010: (NOV, 21),
|
||||
2011: (NOV, 10),
|
||||
2012: (NOV, 27),
|
||||
2013: (NOV, 17),
|
||||
2014: (NOV, 6),
|
||||
2015: (NOV, 25),
|
||||
2016: (NOV, 14),
|
||||
2017: (NOV, 3),
|
||||
2018: (NOV, 22),
|
||||
2019: (NOV, 12),
|
||||
2020: (NOV, 29),
|
||||
2021: (NOV, 18),
|
||||
2022: (NOV, 7),
|
||||
2023: (NOV, 26),
|
||||
2024: (NOV, 15),
|
||||
2025: (NOV, 5),
|
||||
}
|
||||
|
||||
MEDIN_POYA_DATES = {
|
||||
2003: (MAR, 18),
|
||||
2004: (MAR, 6),
|
||||
2005: (MAR, 25),
|
||||
2006: (MAR, 14),
|
||||
2007: (MAR, 3),
|
||||
2008: (MAR, 21),
|
||||
2009: (MAR, 10),
|
||||
2010: (FEB, 28),
|
||||
2011: (MAR, 19),
|
||||
2012: (MAR, 7),
|
||||
2013: (MAR, 26),
|
||||
2014: (MAR, 16),
|
||||
2015: (MAR, 5),
|
||||
2016: (MAR, 22),
|
||||
2017: (MAR, 12),
|
||||
2018: (MAR, 1),
|
||||
2019: (MAR, 20),
|
||||
2020: (MAR, 9),
|
||||
2021: (MAR, 28),
|
||||
2022: (MAR, 17),
|
||||
2023: (MAR, 6),
|
||||
2024: (MAR, 24),
|
||||
2025: (MAR, 13),
|
||||
}
|
||||
|
||||
NAWAM_POYA_DATES = {
|
||||
2003: (FEB, 16),
|
||||
2004: (FEB, 5),
|
||||
2005: (FEB, 23),
|
||||
2006: (FEB, 12),
|
||||
2007: (FEB, 1),
|
||||
2008: (FEB, 20),
|
||||
2009: (FEB, 9),
|
||||
2010: (JAN, 29),
|
||||
2011: (FEB, 17),
|
||||
2012: (FEB, 7),
|
||||
2013: (FEB, 25),
|
||||
2014: (FEB, 14),
|
||||
2015: (FEB, 3),
|
||||
2016: (FEB, 22),
|
||||
2017: (FEB, 10),
|
||||
2018: (JAN, 31),
|
||||
2019: (FEB, 19),
|
||||
2020: (FEB, 8),
|
||||
2021: (FEB, 26),
|
||||
2022: (FEB, 16),
|
||||
2023: (FEB, 5),
|
||||
2024: (FEB, 23),
|
||||
2025: (FEB, 12),
|
||||
}
|
||||
|
||||
NIKINI_POYA_DATES = {
|
||||
2003: (AUG, 11),
|
||||
2004: (AUG, 29),
|
||||
2005: (AUG, 19),
|
||||
2006: (AUG, 9),
|
||||
2007: (AUG, 28),
|
||||
2008: (AUG, 16),
|
||||
2009: (AUG, 5),
|
||||
2010: (AUG, 24),
|
||||
2011: (AUG, 13),
|
||||
2012: (AUG, 1),
|
||||
2013: (AUG, 20),
|
||||
2014: (AUG, 10),
|
||||
2015: (AUG, 29),
|
||||
2016: (AUG, 17),
|
||||
2017: (AUG, 7),
|
||||
2018: (AUG, 25),
|
||||
2019: (AUG, 14),
|
||||
2020: (AUG, 3),
|
||||
2021: (AUG, 22),
|
||||
2022: (AUG, 11),
|
||||
2023: (AUG, 30),
|
||||
2024: (AUG, 19),
|
||||
2025: (AUG, 8),
|
||||
}
|
||||
|
||||
POSON_POYA_DATES = {
|
||||
2003: (JUN, 14),
|
||||
2004: (JUN, 2),
|
||||
2005: (JUN, 21),
|
||||
2006: (JUN, 11),
|
||||
2007: (JUN, 30),
|
||||
2008: (JUN, 18),
|
||||
2009: (JUN, 7),
|
||||
2010: (JUN, 25),
|
||||
2011: (JUN, 15),
|
||||
2012: (JUN, 4),
|
||||
2013: (JUN, 23),
|
||||
2014: (JUN, 12),
|
||||
2015: (JUN, 2),
|
||||
2016: (JUN, 19),
|
||||
2017: (JUN, 8),
|
||||
2018: (JUN, 27),
|
||||
2019: (JUN, 16),
|
||||
2020: (JUN, 5),
|
||||
2021: (JUN, 24),
|
||||
2022: (JUN, 14),
|
||||
2023: (JUN, 3),
|
||||
2024: (JUN, 21),
|
||||
2025: (JUN, 10),
|
||||
}
|
||||
|
||||
UNDUVAP_POYA_DATES = {
|
||||
2003: (DEC, 8),
|
||||
2004: (DEC, 26),
|
||||
2005: (DEC, 15),
|
||||
2006: (DEC, 4),
|
||||
2007: (DEC, 23),
|
||||
2008: (DEC, 12),
|
||||
2009: (DEC, 1),
|
||||
2010: (DEC, 20),
|
||||
2011: (DEC, 10),
|
||||
2012: (DEC, 27),
|
||||
2013: (DEC, 16),
|
||||
2014: (DEC, 6),
|
||||
2015: (DEC, 24),
|
||||
2016: (DEC, 13),
|
||||
2017: (DEC, 3),
|
||||
2018: (DEC, 22),
|
||||
2019: (DEC, 11),
|
||||
2020: (DEC, 29),
|
||||
2021: (DEC, 18),
|
||||
2022: (DEC, 7),
|
||||
2023: (DEC, 26),
|
||||
2024: (DEC, 14),
|
||||
2025: (DEC, 4),
|
||||
}
|
||||
|
||||
VAP_POYA_DATES = {
|
||||
2003: (OCT, 9),
|
||||
2004: (OCT, 27),
|
||||
2005: (OCT, 17),
|
||||
2006: (OCT, 6),
|
||||
2007: (OCT, 25),
|
||||
2008: (OCT, 14),
|
||||
2009: (OCT, 3),
|
||||
2010: (OCT, 22),
|
||||
2011: (OCT, 11),
|
||||
2012: (OCT, 29),
|
||||
2013: (OCT, 18),
|
||||
2014: (OCT, 8),
|
||||
2015: (OCT, 27),
|
||||
2016: (OCT, 15),
|
||||
2017: (OCT, 5),
|
||||
2018: (OCT, 24),
|
||||
2019: (OCT, 13),
|
||||
2020: (OCT, 30),
|
||||
2021: (OCT, 20),
|
||||
2022: (OCT, 9),
|
||||
2023: (OCT, 28),
|
||||
2024: (OCT, 17),
|
||||
2025: (OCT, 6),
|
||||
}
|
||||
|
||||
VESAK_POYA_DATES = {
|
||||
2003: (MAY, 15),
|
||||
2004: (MAY, 4),
|
||||
2005: (MAY, 23),
|
||||
2006: (MAY, 12),
|
||||
2007: (MAY, 1),
|
||||
2008: (MAY, 19),
|
||||
2009: (MAY, 8),
|
||||
2010: (MAY, 27),
|
||||
2011: (MAY, 17),
|
||||
2012: (MAY, 5),
|
||||
2013: (MAY, 24),
|
||||
2014: (MAY, 14),
|
||||
2015: (MAY, 3),
|
||||
2016: (MAY, 21),
|
||||
2017: (MAY, 10),
|
||||
2018: (APR, 29),
|
||||
2019: (MAY, 18),
|
||||
2020: (MAY, 7),
|
||||
2021: (MAY, 26),
|
||||
2022: (MAY, 15),
|
||||
2023: (MAY, 5),
|
||||
2024: (MAY, 23),
|
||||
2025: (MAY, 12),
|
||||
}
|
||||
|
||||
def _get_holiday(self, holiday: str, year: int) -> tuple[Optional[date], bool]:
|
||||
estimated_dates = getattr(self, f"{holiday}_DATES", {})
|
||||
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
|
||||
dt = exact_dates.get(year, estimated_dates.get(year, ()))
|
||||
return date(year, *dt) if dt else None, year not in exact_dates
|
||||
|
||||
def _get_holiday_set(self, holiday: str, year: int) -> Iterable[tuple[date, bool]]:
|
||||
estimated_dates = getattr(self, f"{holiday}_DATES", {})
|
||||
exact_dates = getattr(self, f"{holiday}_DATES_{_CustomCalendar.CUSTOM_ATTR_POSTFIX}", {})
|
||||
for year in (year - 1, year):
|
||||
for dt in _normalize_tuple(exact_dates.get(year, estimated_dates.get(year, ()))):
|
||||
yield date(year, *dt), year not in exact_dates
|
||||
|
||||
def bak_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(BAK_POYA, year)
|
||||
|
||||
def binara_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(BINARA_POYA, year)
|
||||
|
||||
def duruthu_poya_date(self, year: int) -> Iterable[tuple[date, bool]]:
|
||||
return self._get_holiday_set(DURUTHU_POYA, year)
|
||||
|
||||
def esala_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(ESALA_POYA, year)
|
||||
|
||||
def il_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(IL_POYA, year)
|
||||
|
||||
def medin_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(MEDIN_POYA, year)
|
||||
|
||||
def nawam_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(NAWAM_POYA, year)
|
||||
|
||||
def nikini_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(NIKINI_POYA, year)
|
||||
|
||||
def poson_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(POSON_POYA, year)
|
||||
|
||||
def unduvap_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(UNDUVAP_POYA, year)
|
||||
|
||||
def vap_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(VAP_POYA, year)
|
||||
|
||||
def vesak_poya_date(self, year: int) -> tuple[Optional[date], bool]:
|
||||
return self._get_holiday(VESAK_POYA, year)
|
||||
|
||||
|
||||
class _CustomSinhalaHolidays(_CustomCalendar, _SinhalaLunar):
|
||||
pass
|
||||
799
.venv/lib/python3.12/site-packages/holidays/calendars/thai.py
Normal file
799
.venv/lib/python3.12/site-packages/holidays/calendars/thai.py
Normal file
@ -0,0 +1,799 @@
|
||||
# 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)
|
||||
|
||||
from datetime import date
|
||||
from functools import lru_cache
|
||||
from typing import Optional
|
||||
|
||||
from holidays.calendars.gregorian import _timedelta
|
||||
|
||||
KHMER_CALENDAR = "KHMER_CALENDAR"
|
||||
THAI_CALENDAR = "THAI_CALENDAR"
|
||||
|
||||
|
||||
class _ThaiLunisolar:
|
||||
"""Thai Lunar Calendar Holidays.
|
||||
|
||||
Works from 1913 (B.E. 2456/2455) onwards until 2157 (B.E. 2700), as we only have
|
||||
Thai year-type data for cross-checking through that period.
|
||||
|
||||
## The basics of the Thai Lunar Calendar:
|
||||
|
||||
3-year types for calendar intercalation:
|
||||
* Pakatimat (Normal Year):
|
||||
Consists of 12 months, totaling 354 days.
|
||||
* Athikawan (Extra-Day Year):
|
||||
Adds one extra day to the 7th month, totaling 355 days for synodic month correction.
|
||||
* Athikamat (Extra-Month Year):
|
||||
Adds one extra 8th month, totaling 384 days for sidereal year correction.
|
||||
|
||||
Months alternate between 30 (even months) and 29 (odd months) days.
|
||||
|
||||
The waxing phase (Full Moon) lasts 15 days, while the waning phase (New Moon) lasts
|
||||
14 days for odd months (except Month 7 in Athikawan years), 15 days for even months.
|
||||
|
||||
The second "Month 8" for Athikamat years is called "Month 8.8"
|
||||
(read as "the latter 8th month"), with all observed holidays
|
||||
delayed from the usual calendar by 30 days.
|
||||
|
||||
Implemented Thai Lunar Calendar holiday methods:
|
||||
* Magha Puja / Makha Bucha / Meak Bochea:
|
||||
15th Waxing Day (Full Moon) of Month 3 (On Month 4 for Athikamat Years).
|
||||
`KHMER_CALENDAR` always falls on Month 3.
|
||||
|
||||
* Vesak / Visakha Bucha / Visaka Bochea:
|
||||
15th Waxing Day (Full Moon) of Month 6 (On Month 7 for Athikamat Years).
|
||||
`KHMER_CALENDAR` always falls on Month 6.
|
||||
|
||||
* Cambodian Royal Ploughing Ceremony / Preah Neangkol:
|
||||
4th Waning Day of Month 6 (On Month 7 for Athikamat Years).
|
||||
Defaults to `KHMER_CALENDAR` (its sole user).
|
||||
|
||||
* Buddha's Cremation Day / Atthami Bucha:
|
||||
8th Waning Day of Month 6 (On Month 7 for Athikamat Years).
|
||||
`KHMER_CALENDAR` always falls on Month 6.
|
||||
|
||||
* Asalha Puja / Asarnha Bucha:
|
||||
15th Waxing Day (Full Moon) of Month 8 (On Month 8.8 for Athikamat Years).
|
||||
|
||||
* Buddhist Lent Day / Wan Khao Phansa:
|
||||
1st Waning Day of Month 8 (On Month 8.8 for Athikamat Years).
|
||||
|
||||
* Boun Haw Khao Padapdin / Boon Khao Padap Din:
|
||||
14th Waning Day (New Moon) of Month 9.
|
||||
|
||||
* Boun Haw Khao Salark / Boon Khao Sak:
|
||||
15th Waxing Day (Full Moon) of Month 10.
|
||||
|
||||
* Pchum Ben / Prachum Bandar:
|
||||
15th Waning Day (New Moon) of Month 10.
|
||||
|
||||
* Ok Boun Suang Huea / Vientiane Boat Racing Festival:
|
||||
1st Waning Day (New Moon) of Month 11.
|
||||
|
||||
* Loy Krathong / Boun That Louang / Bon Om Touk:
|
||||
15th Waxing Day (Full Moon) of Month 12.
|
||||
|
||||
Other Thai Lunar Calendar holidays:
|
||||
* Thai Royal Ploughing Ceremony / Raeknakhwan:
|
||||
Court astrologers choose the auspicious dates based on the Thai Lunar Calendar,
|
||||
but these dates do not follow a predictable pattern.
|
||||
See the specific section in `thailand.py` for more details.
|
||||
|
||||
* End of Buddhist Lent Day / Ok Phansa:
|
||||
15th Waxing Day (Full Moon) of Month 11
|
||||
(Currently calculated based on Asalha Puja / Asarnha Bucha method).
|
||||
|
||||
Notes:
|
||||
The following code is based on Ninenik Narkdee's PHP implementation,
|
||||
and we're thankful for his work.
|
||||
|
||||
References:
|
||||
* <https://web.archive.org/web/20241016080156/https://www.ninenik.com/แนวทางฟังก์ชั่น_php_อย่างง่ายกับการหาวันข้างขึ้นข้างแรม-1021.html>
|
||||
* <https://web.archive.org/web/20250119171416/https://www.myhora.com/ปฏิทิน/ปฏิทิน-พ.ศ.2560.aspx>
|
||||
|
||||
Example:
|
||||
|
||||
>>> from holidays.calendars.thai import _ThaiLunisolar
|
||||
>>> thls = _ThaiLunisolar()
|
||||
>>> print(thls.visakha_bucha_date(2010))
|
||||
2010-05-28
|
||||
|
||||
"""
|
||||
|
||||
# Athikawan (Extra-Day Year) list goes from 1914-2157 C.E.
|
||||
# Copied off from 1757-2157 (B.E. 2300-2700) Thai Lunar Calendar
|
||||
ATHIKAWAN_YEARS_GREGORIAN = {
|
||||
1914,
|
||||
1917,
|
||||
1925,
|
||||
1929,
|
||||
1933,
|
||||
1936,
|
||||
1945,
|
||||
1949,
|
||||
1952,
|
||||
1957,
|
||||
1963,
|
||||
1970,
|
||||
1973,
|
||||
1979,
|
||||
1987,
|
||||
1990,
|
||||
1997,
|
||||
2000,
|
||||
2006,
|
||||
2009,
|
||||
2016,
|
||||
2020,
|
||||
2025,
|
||||
2032,
|
||||
2035,
|
||||
2043,
|
||||
2046,
|
||||
2052,
|
||||
2055,
|
||||
2058,
|
||||
2067,
|
||||
2071,
|
||||
2076,
|
||||
2083,
|
||||
2086,
|
||||
2092,
|
||||
2097,
|
||||
2103,
|
||||
2109,
|
||||
2111,
|
||||
2117,
|
||||
2121,
|
||||
2126,
|
||||
2133,
|
||||
2136,
|
||||
2142,
|
||||
2147,
|
||||
2153,
|
||||
}
|
||||
|
||||
# Athikamat (Extra-Month Year) list goes from 1914-2157 C.E.:
|
||||
# Copied off from 1757-2157 (B.E. 2300-2700) Thai Lunar Calendar
|
||||
# Approx formula as follows: (common_era-78)-0.45222)%2.7118886 < 1
|
||||
ATHIKAMAT_YEARS_GREGORIAN = {
|
||||
1915,
|
||||
1918,
|
||||
1920,
|
||||
1923,
|
||||
1926,
|
||||
1928,
|
||||
1931,
|
||||
1934,
|
||||
1937,
|
||||
1939,
|
||||
1942,
|
||||
1944,
|
||||
1947,
|
||||
1950,
|
||||
1953,
|
||||
1956,
|
||||
1958,
|
||||
1961,
|
||||
1964,
|
||||
1966,
|
||||
1969,
|
||||
1972,
|
||||
1975,
|
||||
1977,
|
||||
1980,
|
||||
1983,
|
||||
1985,
|
||||
1988,
|
||||
1991,
|
||||
1994,
|
||||
1996,
|
||||
1999,
|
||||
2002,
|
||||
2004,
|
||||
2007,
|
||||
2010,
|
||||
2012,
|
||||
2015,
|
||||
2018,
|
||||
2021,
|
||||
2023,
|
||||
2026,
|
||||
2029,
|
||||
2031,
|
||||
2034,
|
||||
2037,
|
||||
2040,
|
||||
2042,
|
||||
2045,
|
||||
2048,
|
||||
2050,
|
||||
2053,
|
||||
2056,
|
||||
2059,
|
||||
2062,
|
||||
2064,
|
||||
2066,
|
||||
2069,
|
||||
2072,
|
||||
2074,
|
||||
2077,
|
||||
2080,
|
||||
2082,
|
||||
2085,
|
||||
2088,
|
||||
2091,
|
||||
2094,
|
||||
2096,
|
||||
2099,
|
||||
2101,
|
||||
2104,
|
||||
2107,
|
||||
2112,
|
||||
2114,
|
||||
2116,
|
||||
2119,
|
||||
2122,
|
||||
2124,
|
||||
2127,
|
||||
2130,
|
||||
2132,
|
||||
2135,
|
||||
2138,
|
||||
2141,
|
||||
2144,
|
||||
2146,
|
||||
2149,
|
||||
2151,
|
||||
2154,
|
||||
2157,
|
||||
}
|
||||
|
||||
# While Buddhist Holy Days have been observed since the 1900s
|
||||
# Thailand's Public Holiday Act wasn't codified until 1914 (B.E. 2457)
|
||||
# and that our array only goes up to B.E. 2700; We'll thus only populate
|
||||
# the data for 1914-2157 (B.E. 2457-2700).
|
||||
# Sources: หนังสือเวียนกรมการปกครอง กระทรวงมหาดไทย มท 0310.1/ว4 5 ก.พ. 2539
|
||||
START_DATE = date(1913, 11, 28)
|
||||
START_YEAR = 1914
|
||||
END_YEAR = 2157
|
||||
|
||||
def __init__(self, calendar=THAI_CALENDAR) -> None:
|
||||
self.__verify_calendar(calendar)
|
||||
self.__calendar = calendar
|
||||
|
||||
@staticmethod
|
||||
def __is_khmer_calendar(calendar) -> bool:
|
||||
"""Check if the given calendar is the Khmer calendar.
|
||||
|
||||
Args:
|
||||
calendar:
|
||||
The calendar identifier to check.
|
||||
|
||||
Returns:
|
||||
True if the calendar is `KHMER_CALENDAR`, False otherwise.
|
||||
"""
|
||||
return calendar == KHMER_CALENDAR
|
||||
|
||||
@staticmethod
|
||||
def __verify_calendar(calendar) -> None:
|
||||
"""Verify calendar type."""
|
||||
if calendar not in {KHMER_CALENDAR, THAI_CALENDAR}:
|
||||
raise ValueError(
|
||||
f"Unknown calendar name: {calendar}. Use `KHMER_CALENDAR` or `THAI_CALENDAR`."
|
||||
)
|
||||
|
||||
@lru_cache
|
||||
def _get_start_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the start date of that particular Thai Lunar Calendar Year.
|
||||
|
||||
This usually falls in November or December of the previous Gregorian
|
||||
year in question. Should the year be outside of working scope
|
||||
(1914-2157: B.E 2457-2700), this will returns None instead.
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
The start date of Thai Lunar Calendar for a Gregorian year.
|
||||
"""
|
||||
if year < _ThaiLunisolar.START_YEAR or year > _ThaiLunisolar.END_YEAR:
|
||||
return None
|
||||
|
||||
delta_days = 354 * (year - _ThaiLunisolar.START_YEAR)
|
||||
for iter_year in range(_ThaiLunisolar.START_YEAR, year):
|
||||
if iter_year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days += 30
|
||||
elif iter_year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days += 1
|
||||
|
||||
return _timedelta(_ThaiLunisolar.START_DATE, delta_days)
|
||||
|
||||
def makha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Makha Bucha.
|
||||
|
||||
Also known as "Magha Puja", "Makha Buxha" and "Meak Bochea".
|
||||
This coincides with the 15th Waxing Day of Month 3
|
||||
in Thai Lunar Calendar, or Month 4 in Athikamat years.
|
||||
|
||||
`KHMER_CALENDAR` will always use Month 3 regardless of year type.
|
||||
|
||||
To calculate, we use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
15th Waxing Day of Month 4 or 29[1] + 30[2] + 29[3] + 15[4] -1 = 102
|
||||
|
||||
* Athikawan:
|
||||
15th Waxing Day of Month 3 or 29[1] + 30[2] + 15[3] -1 = 73
|
||||
|
||||
* Pakatimat:
|
||||
15th Waxing Day of Month 3 or 29[1] + 30[2] + 15[3] -1 = 73
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
calendar:
|
||||
Calendar type, this defaults to THAI_CALENDAR.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Makha Bucha.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
calendar = calendar or self.__calendar
|
||||
self.__verify_calendar(calendar)
|
||||
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
return _timedelta(
|
||||
start_date,
|
||||
+102
|
||||
if (
|
||||
year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN
|
||||
and not self.__is_khmer_calendar(calendar)
|
||||
)
|
||||
else +73,
|
||||
)
|
||||
|
||||
def visakha_bucha_date(self, year: int, calendar=None) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Visakha Bucha.
|
||||
|
||||
Also known as "Vesak" and "Buddha Day". This coincides with
|
||||
the 15th Waxing Day of Month 6 in Thai Lunar Calendar, or Month 7 in Athikamat years.
|
||||
|
||||
`KHMER_CALENDAR` will always use Month 6 regardless of year type.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
15th Waxing Day of Month 7 or 177[1-6] + 15[7] -1 = 191
|
||||
|
||||
* Athikawan:
|
||||
15th Waxing Day of Month 6 or 147[1-5] + 15[6] -1 = 161
|
||||
|
||||
* Pakatimat:
|
||||
15th Waxing Day of Month 6 or 147[1-5] + 15[6] -1 = 161
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
calendar:
|
||||
Calendar type, this defaults to THAI_CALENDAR.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Visakha Bucha.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
calendar = calendar or self.__calendar
|
||||
self.__verify_calendar(calendar)
|
||||
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
return _timedelta(
|
||||
start_date,
|
||||
+191
|
||||
if (
|
||||
year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN
|
||||
and not self.__is_khmer_calendar(calendar)
|
||||
)
|
||||
else +161,
|
||||
)
|
||||
|
||||
def preah_neangkoal_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Preah Neangkoal.
|
||||
|
||||
Also known as "Cambodian Royal Ploughing Ceremony". This always
|
||||
coincides with the 4th Waning Day of Month 6 in Khmer Lunar Calendar.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
4th Waning Day of Month 6 (Khmer Lunar Calendar) or 177[1-5] + 19[6] -1 = 165
|
||||
|
||||
* Athikawan:
|
||||
4th Waning Day of Month 6 or 147[1-5] + 19[6] -1 = 165
|
||||
|
||||
* Pakatimat:
|
||||
4th Waning Day of Month 6 or 147[1-5] + 19[6] -1 = 165
|
||||
|
||||
Or as in simpler terms: "Visakha Bucha" (Khmer Lunar Calendar) +4.
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Preah Neangkoal.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
return _timedelta(start_date, +165)
|
||||
|
||||
def atthami_bucha_date(self, year: int, calendar=None) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Atthami Bucha.
|
||||
|
||||
Also known as "Buddha's Cremation Day". This coincides with
|
||||
the 8th Waning Day of Month 6 in Thai Lunar Calendar, or Month 7 in Athikamat years.
|
||||
|
||||
`KHMER_CALENDAR` will always use Month 6 regardless of year type.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
8th Waning Day of Month 7 or 177[1-6] + 23[7] -1 = 199
|
||||
|
||||
* Athikawan:
|
||||
8th Waning Day of Month 6 or 147[1-5] + 23[6] -1 = 169
|
||||
|
||||
* Pakatimat:
|
||||
8th Waning Day of Month 6 or 147[1-5] + 23[6] -1 = 169
|
||||
|
||||
Or as in simpler terms: "Visakha Bucha" +8
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
calendar:
|
||||
Calendar type, this defaults to THAI_CALENDAR.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Atthami Bucha.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
calendar = calendar or self.__calendar
|
||||
self.__verify_calendar(calendar)
|
||||
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
return _timedelta(
|
||||
start_date,
|
||||
+199
|
||||
if (
|
||||
year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN
|
||||
and not self.__is_khmer_calendar(calendar)
|
||||
)
|
||||
else +169,
|
||||
)
|
||||
|
||||
def asarnha_bucha_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Asarnha Bucha.
|
||||
|
||||
Also known as "Asalha Puja". This coincides with
|
||||
the 15th Waxing Day of Month 8 in Thai Lunar Calendar,
|
||||
or Month 8.8 in Athikamat years.
|
||||
|
||||
Lao Start of Buddhist Lent start on this day (1-day earlier than Thai and Khmer ones).
|
||||
|
||||
To calculate, we use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
15th Waxing Day of Month 8/8 or 177[1-6] + 29[7] + 30[8] + 15[8.8] -1 = 250
|
||||
|
||||
* Athikawan:
|
||||
15th Waxing Day of Month 8 or 177[1-6] + 30[7] + 15[8] -1 = 221
|
||||
|
||||
* Pakatimat:
|
||||
15th Waxing Day of Month 8 or 177[1-6] + 29[7] + 15[8] -1 = 220
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Asarnha Bucha.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days = +250
|
||||
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days = +221
|
||||
else:
|
||||
delta_days = +220
|
||||
return _timedelta(start_date, delta_days)
|
||||
|
||||
def khao_phansa_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Khao Phansa.
|
||||
|
||||
Also known as "(Start of) Buddhist Lent" and "Start of Vassa".
|
||||
This coincides with the 1st Waning Day of Month 8
|
||||
in Thai Lunar Calendar, or Month 8.8 in Athikamat years.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
1st Waning Day of Month 8.8 or 177[1-6] + 29[7] + 30[8] + 16[8.8] -1 = 251
|
||||
|
||||
* Athikawan:
|
||||
1st Waning Day of Month 8 or 177[1-6] + 30[7] + 16[8] -1 = 222
|
||||
|
||||
* Pakatimat:
|
||||
1st Waning Day of Month 8 or 177[1-6] + 29[7] + 16[8] -1 = 221
|
||||
|
||||
Or as in simpler terms: "Asarnha Bucha" +1
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Khao Phansa.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days = +251
|
||||
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days = +222
|
||||
else:
|
||||
delta_days = +221
|
||||
return _timedelta(start_date, delta_days)
|
||||
|
||||
def boun_haw_khao_padapdin_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Boun Haw Khao Padapdin.
|
||||
|
||||
Also known as "Boon Khao Padap Din".
|
||||
This coincides with the 14th Waning Day of Month 9 in Thai Lunar Calendar.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
14th Waning Day of Month 9 or 236[1-8] + 30[8.8] + 29[9] -1 = 294
|
||||
|
||||
* Athikawan:
|
||||
14th Waning Day of Month 9 or 236[1-8] + 1[7] + 29[9] -1 = 265
|
||||
|
||||
* Pakatimat:
|
||||
14th Waning Day of Month 9 or 236[1-8] + 29[9] -1 = 264
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Boun Haw Khao Padapdin.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days = +294
|
||||
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days = +265
|
||||
else:
|
||||
delta_days = +264
|
||||
return _timedelta(start_date, delta_days)
|
||||
|
||||
def boun_haw_khao_salark_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Boun Haw Khao Salark.
|
||||
|
||||
Also known as "Boon Khao Sak".
|
||||
This coincides with the 15th Waxing Day of Month 10 in Thai Lunar Calendar.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
15th Waxing Day of Month 10 or 265[1-9] + 30[8.8] + 15[10] -1 = 309
|
||||
|
||||
* Athikawan:
|
||||
15th Waxing Day of Month 10 or 265[1-9] + 1[7] + 15[10] -1 = 280
|
||||
|
||||
* Pakatimat:
|
||||
15th Waxing Day of Month 10 or 265[1-9] + 15[10] -1 = 279
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Boun Haw Khao Salark.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days = +309
|
||||
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days = +280
|
||||
else:
|
||||
delta_days = +279
|
||||
return _timedelta(start_date, delta_days)
|
||||
|
||||
def pchum_ben_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Pchum Ben.
|
||||
|
||||
Also known as "Prachum Bandar".
|
||||
This coincides with the 15th Waning Day of Month 10 in Thai Lunar Calendar.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
15th Waning Day of Month 10 or 265[1-9] + 30[8.8] + 30[10] -1 = 324
|
||||
|
||||
* Athikawan:
|
||||
15th Waning Day of Month 10 or 265[1-9] + 1[7] + 30[10] -1 = 295
|
||||
|
||||
* Pakatimat:
|
||||
15th Waning Day of Month 10 or 265[1-9] + 30[10] -1 = 294
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Pchum Ben.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days = +324
|
||||
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days = +295
|
||||
else:
|
||||
delta_days = +294
|
||||
return _timedelta(start_date, delta_days)
|
||||
|
||||
def ok_phansa_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Ok Phansa.
|
||||
|
||||
Also known as "End of Buddhist Lent" and "End of Vassa".
|
||||
This coincides with the 15th Waxing Day of Month 11 in Thai Lunar Calendar.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
15th Waxing Day of Month 11 or 295[1-10] + 30[8.8] + 15[11] -1 = 339
|
||||
|
||||
* Athikawan:
|
||||
15th Waxing Day of Month 11 or 295[1-10] + 1[7] + 15[11] -1 = 310
|
||||
|
||||
* Pakatimat:
|
||||
15th Waxing Day of Month 11 or 295[1-10] + 15[11] -1 = 309
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Ok Phansa.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days = +339
|
||||
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days = +310
|
||||
else:
|
||||
delta_days = +309
|
||||
return _timedelta(start_date, delta_days)
|
||||
|
||||
def boun_suang_heua_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Ok Boun Suang Huea.
|
||||
|
||||
Boun Suang Huea Nakhone Luang Prabang, also known as "Vientiane Boat Racing Festival".
|
||||
This coincides with the 1st Waning Day of Month 11 in Thai Lunar Calendar.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
1st Waning Day of Month 11 or 295[1-10] + 30[8.8] + 16[11] -1 = 340
|
||||
|
||||
* Athikawan:
|
||||
1st Waning Day of Month 11 or 295[1-10] + 1[7] + 16[11] -1 = 311
|
||||
|
||||
* Pakatimat:
|
||||
1st Waning Day of Month 11 or 295[1-10] + 16[11] -1 = 310
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Boun Suang Huea.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days = +340
|
||||
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days = +311
|
||||
else:
|
||||
delta_days = +310
|
||||
return _timedelta(start_date, delta_days)
|
||||
|
||||
def loy_krathong_date(self, year: int) -> Optional[date]:
|
||||
"""Calculate the estimated Gregorian date of Loy Krathong.
|
||||
|
||||
Also known as "Boun That Louang" and "Bon Om Touk".
|
||||
This coincides with the 15th Waxing Day of Month 12 in Thai Lunar Calendar.
|
||||
|
||||
To calculate, we use use the following time delta:
|
||||
|
||||
* Athikamat:
|
||||
15th Waxing Day of Month 12 or 324[1-11] + 30[8.8] + 15[11] -1 = 368
|
||||
|
||||
* Athikawan:
|
||||
15th Waxing Day of Month 12 or 324[1-11] + 1[7] + 15[11] -1 = 339
|
||||
|
||||
* Pakatimat:
|
||||
15th Waxing Day of Month 12 or 324[1-11] + 15[11] -1 = 338
|
||||
|
||||
Args:
|
||||
year:
|
||||
The Gregorian year.
|
||||
|
||||
Returns:
|
||||
Estimated Gregorian date of Loy Krathong.
|
||||
Returns None if the Gregorian year input is invalid.
|
||||
"""
|
||||
start_date = self._get_start_date(year)
|
||||
if not start_date:
|
||||
return None
|
||||
|
||||
if year in _ThaiLunisolar.ATHIKAMAT_YEARS_GREGORIAN:
|
||||
delta_days = +368
|
||||
elif year in _ThaiLunisolar.ATHIKAWAN_YEARS_GREGORIAN:
|
||||
delta_days = +339
|
||||
else:
|
||||
delta_days = +338
|
||||
return _timedelta(start_date, delta_days)
|
||||
Reference in New Issue
Block a user