1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488
|
# 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 holidays.calendars.hindu import _HinduLunisolar
from holidays.groups.eastern import EasternCalendarHolidays
class HinduCalendarHolidays(EasternCalendarHolidays):
"""
Hindu lunisolar calendar holidays.
"""
def __init__(self, cls=None, *, show_estimated=False) -> None:
self._hindu_calendar = cls() if cls else _HinduLunisolar()
self._hindu_calendar_show_estimated = show_estimated
def _add_hindu_calendar_holiday(
self, name: str, dt_estimated: tuple[date | None, bool], days_delta: int = 0
) -> date | None:
"""
Add Hindu calendar holiday.
Adds customizable estimation label to holiday name if holiday date
is an estimation.
"""
return self._add_eastern_calendar_holiday(
name,
dt_estimated,
show_estimated=self._hindu_calendar_show_estimated,
days_delta=days_delta,
)
def _add_hindu_calendar_holiday_set(
self, name: str, dts_estimated: Iterable[tuple[date, bool]], days_delta: int = 0
) -> set[date]:
"""
Add Hindu calendar holidays.
Adds customizable estimation label to holiday name if holiday date
is an estimation.
"""
return self._add_eastern_calendar_holiday_set(
name,
dts_estimated,
show_estimated=self._hindu_calendar_show_estimated,
days_delta=days_delta,
)
def _add_bhai_dooj(self, name) -> date | None:
"""
Add Bhai Dooj.
Bhai Dooj, also known as Bhai Tika or Bhaiya Dooj, is a Hindu festival celebrating the bond
between brothers and sisters. It is observed two days after Diwali on the second lunar day
of the Shukla Paksha in the Hindu month of Kartika.
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.govardhan_puja_date(self._year), days_delta=+1
)
def _add_buddha_purnima(self, name) -> date | None:
"""
Add Buddha Purnima.
Buddha Purnima, also known as Vesak, commemorates the birth, enlightenment,
and passing of Gautama Buddha. It falls on the full moon day of the
Hindu month of Vaisakha (April-May).
https://en.wikipedia.org/wiki/Vesak
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.buddha_purnima_date(self._year)
)
def _add_chhath_puja(self, name) -> date | None:
"""
Add Chhath Puja.
Chhath Puja is a Hindu festival dedicated to the Sun God (Surya).
It is observed six days after Diwali in the month of Kartika (October-November).
https://en.wikipedia.org/wiki/Chhath
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.chhath_puja_date(self._year)
)
def _add_diwali(self, name) -> date | None:
"""
Add Diwali Festival.
Diwali (Deepavali, Festival of Lights) is one of the most important
festivals in Indian religions. It is celebrated during the Hindu
lunisolar months of Ashvin and Kartika (between mid-October and
mid-November).
https://en.wikipedia.org/wiki/Diwali
"""
return self._add_hindu_calendar_holiday(name, self._hindu_calendar.diwali_date(self._year))
def _add_diwali_india(self, name) -> date | None:
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.diwali_india_date(self._year)
)
def _add_dussehra(self, name) -> date | None:
"""
Add Dussehra Festival.
Dussehra (Vijayadashami) is a major Hindu festival that marks the end
of Navratri. It is celebrated on the 10th day of the Hindu lunisolar
month of Ashvin (September-October).
https://en.wikipedia.org/wiki/Vijayadashami
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.dussehra_date(self._year)
)
def _add_ganesh_chaturthi(self, name) -> date | None:
"""
Add Ganesh Chaturthi.
Ganesh Chaturthi is a Hindu festival celebrating the birth of Lord Ganesha.
It falls on the fourth day of the Hindu month of Bhadrapada (August/September).
https://en.wikipedia.org/wiki/Ganesh_Chaturthi
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.ganesh_chaturthi_date(self._year)
)
def _add_gau_krida(self, name) -> date | None:
"""
Add Gau Krida.
Gau Krida, is celebrated the day after Diwali to honor cows.
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.govardhan_puja_date(self._year), days_delta=-1
)
def _add_govardhan_puja(self, name) -> date | None:
"""
Add Govardhan Puja.
Govardhan Puja, also known as Annakut, is celebrated after Diwali
to honor Lord Krishna. It falls on the first lunar day of the Hindu month of Kartika.
https://en.wikipedia.org/wiki/Govardhan_Puja
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.govardhan_puja_date(self._year)
)
def _add_gudi_padwa(self, name) -> date | None:
"""
Add Gudi Padwa / Ugadi.
Gudi Padwa is the traditional New Year festival celebrated in
Maharashtra. On the same day, the festival is also observed as
Ugadi in Karnataka, Telangana, and Andhra Pradesh.
It falls on the first day of Chaitra (March–April) according to
the Hindu lunisolar calendar.
References:
* https://en.wikipedia.org/wiki/Gudi_Padwa
* https://en.wikipedia.org/wiki/Ugadi
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.gudi_padwa_date(self._year)
)
def _add_guru_gobind_singh_jayanti(self, name) -> set[date]:
"""
Add Guru Gobind Singh Jayanti.
Guru Gobind Singh Jayanti commemorates the birth anniversary of
Guru Gobind Singh, the tenth Sikh Guru. It follows the Nanakshahi calendar.
https://en.wikipedia.org/wiki/Guru_Gobind_Singh
"""
return self._add_hindu_calendar_holiday_set(
name, self._hindu_calendar.guru_gobind_singh_jayanti_date(self._year)
)
def _add_guru_nanak_jayanti(self, name) -> date | None:
"""
Add Guru Nanak Jayanti.
Guru Nanak Jayanti celebrates the birth anniversary of Guru Nanak,
the founder of Sikhism. It is observed on the full moon day of
Kartik (October-November).
https://en.wikipedia.org/wiki/Guru_Nanak_Gurpurab
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.guru_nanak_jayanti_date(self._year)
)
def _add_gyalpo_losar(self, name) -> date | None:
"""
Add Gyalpo Losar.
Gyalpo Losar marks the Tibetan New Year and is widely celebrated by the
Tibetan and Sherpa communities in Nepal. It falls on the first day of the
Tibetan lunar calendar, typically in February or March.
https://en.wikipedia.org/wiki/Gyalpo_Losar
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.gyalpo_losar_date(self._year)
)
def _add_nepal_holi(self, name) -> date | None:
"""
Add Holi Festival for Nepal (Mountain & Hilly).
Holi, known as the Festival of Colors, is a Hindu festival that marks
the arrival of spring. It is celebrated on the full moon day of the
Hindu month of Phalguna (February/March).
https://en.wikipedia.org/wiki/Holi
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.holi_date(self._year), days_delta=-1
)
def _add_holi(self, name) -> date | None:
"""
Add Holi Festival.
Holi, known as the Festival of Colors, is a Hindu festival that marks
the arrival of spring. It is celebrated on the full moon day of the
Hindu month of Phalguna (February/March).
https://en.wikipedia.org/wiki/Holi
"""
return self._add_hindu_calendar_holiday(name, self._hindu_calendar.holi_date(self._year))
def _add_janmashtami(self, name) -> date | None:
"""
Add Janmashtami.
Janmashtami is a Hindu festival that celebrates the birth of Lord Krishna.
It falls on the eighth day of the Hindu month of Bhadrapada (August/September).
https://en.wikipedia.org/wiki/Krishna_Janmashtami
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.janmashtami_date(self._year)
)
def _add_maha_saptami(self, name) -> date | None:
"""
Add Maha Saptami.
Maha Saptami is the seventh day of Navratri, dedicated to Goddess Durga.
It is observed in Ashvin (September-October).
https://en.wikipedia.org/wiki/Navaratri
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.maha_ashtami_date(self._year), days_delta=-1
)
def _add_maha_ashtami(self, name) -> date | None:
"""
Add Maha Ashtami.
Maha Ashtami is the eighth day of Navratri, dedicated to Goddess Durga.
It is observed in Ashvin (September-October).
https://en.wikipedia.org/wiki/Navaratri
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.maha_ashtami_date(self._year)
)
def _add_maha_navami(self, name) -> date | None:
"""
Add Maha Navami.
Maha Navami is the ninth day of Navratri, dedicated to Goddess Durga.
It is observed in Ashvin (September-October).
https://en.wikipedia.org/wiki/Navaratri
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.maha_navami_date(self._year)
)
def _add_maha_shivaratri(self, name) -> date | None:
"""
Add Maha Shivaratri.
Maha Shivaratri is a Hindu festival dedicated to Lord Shiva. It is celebrated
on the 14th night of the Hindu month of Phalguna (February/March).
https://en.wikipedia.org/wiki/Maha_Shivaratri
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.maha_shivaratri_date(self._year)
)
def _add_mahavir_jayanti(self, name) -> date | None:
"""
Add Mahavir Jayanti.
Mahavir Jayanti celebrates the birth of Lord Mahavira, the 24th
Tirthankara of Jainism. It falls on the 13th day of Chaitra (March-April).
https://en.wikipedia.org/wiki/Mahavir_Jayanti
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.mahavir_jayanti_date(self._year)
)
def _add_makar_sankranti(self, name) -> date | None:
"""
Add Makar Sankranti.
Makar Sankranti is a Hindu festival that marks the transition of the Sun
into Capricorn (Makar). It is celebrated on January 14th or 15th every year.
https://en.wikipedia.org/wiki/Makar_Sankranti
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.makar_sankranti_date(self._year)
)
def _add_onam(self, name) -> date | None:
"""
Add Onam.
Onam is a major festival in Kerala, celebrating the homecoming of
King Mahabali. It falls in the month of Chingam (August-September).
https://en.wikipedia.org/wiki/Onam
"""
return self._add_hindu_calendar_holiday(name, self._hindu_calendar.onam_date(self._year))
def _add_papankusha_ekadashi(self, name) -> date | None:
"""
Add Papankusha Ekadashi.
Papankusha Ekadashi is a Hindu festival which occurs on eleventh day on month of
Ashwin (September-October).
https://en.wikipedia.org/wiki/Ekadashi
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.dussehra_date(self._year), days_delta=+1
)
def _add_papankusha_duwadashi(self, name) -> date | None:
"""
Add Papankusha Duwadashi.
Papankusha Duwadashi is a Hindu festival which occurs next day of Papankusha Ekadashi.
https://en.wikipedia.org/wiki/Ekadashi
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.dussehra_date(self._year), days_delta=+2
)
def _add_pongal(self, name) -> date | None:
"""
Add Pongal.
Pongal is a major harvest festival celebrated in Tamil Nadu, India, marking the
beginning of the sun's northward journey (Uttarayana). It is usually observed
on January 14th or 15th every year, coinciding with the Tamil month of Thai.
The festival is dedicated to the Sun God and marks a season of prosperity and abundance.
https://en.wikipedia.org/wiki/Pongal_(festival)
"""
return self._add_hindu_calendar_holiday(name, self._hindu_calendar.pongal_date(self._year))
def _add_raksha_bandhan(self, name) -> date | None:
"""
Add Raksha Bandhan.
Raksha Bandhan is a Hindu festival that celebrates the bond between
brothers and sisters. It falls on the full moon day of the Hindu month
of Shravana (July/August).
https://en.wikipedia.org/wiki/Raksha_Bandhan
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.raksha_bandhan_date(self._year)
)
def _add_ram_navami(self, name) -> date | None:
"""
Add Ram Navami.
Ram Navami is a Hindu festival celebrating the birth of Lord Rama.
It is observed on the ninth day of the Hindu month of Chaitra (March/April).
https://en.wikipedia.org/wiki/Rama_Navami
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.ram_navami_date(self._year)
)
def _add_sharad_navratri(self, name) -> date | None:
"""
Add Navratri / Sharad Navratri.
Navratri is a Hindu festival dedicated to the worship of Goddess Durga.
It is celebrated over nine nights and occurs in the lunar month of Ashvin
(September/October).
https://en.wikipedia.org/wiki/Navratri
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.sharad_navratri_date(self._year)
)
def _add_sonam_losar(self, name) -> date | None:
"""
Add Sonam Losar.
Sonam Losar is the New Year festival celebrated by the Tamang community
in Nepal. It follows the Tibetan lunar calendar and usually falls in
January or February.
https://en.wikipedia.org/wiki/Sonam_Lhosar
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.sonam_losar_date(self._year)
)
def _add_tamu_losar(self, name) -> date | None:
"""
Add Tamu Losar.
Tamu Losar marks the New Year festival of the Gurung community in Nepal.
It is traditionally celebrated on December 30th each year.
https://en.wikipedia.org/wiki/Tamu_Lhosar
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.tamu_losar_date(self._year)
)
def _add_thaipusam(self, name) -> date | None:
"""
Add Thaipusam.
Thaipusam is a Tamil Hindu festival celebrated on the full moon
of the Tamil month of Thai (January/February).
https://en.wikipedia.org/wiki/Thaipusam
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.thaipusam_date(self._year)
)
def _add_thiruvalluvar_day(self, name) -> date | None:
"""
Add Thiruvalluvar Day and Mattu Pongal.
Thiruvalluvar Day and Mattu Pongal are celebrated in Tamil Nadu, India, as part
of the Pongal festival. Thiruvalluvar Day honors the classical Tamil poet and
philosopher Thiruvalluvar, while Mattu Pongal is dedicated to cattle, recognizing
their importance in agriculture. Both events usually fall on January 15th or 16th
each year during the Tamil month of Thai.
https://en.wikipedia.org/wiki/Thiruvalluvar_Day
https://en.wikipedia.org/wiki/Pongal_(festival)#Mattu_Pongal
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.pongal_date(self._year), days_delta=+1
)
def _add_uzhavar_thirunal(self, name) -> date | None:
"""
Add Uzhavar Thirunal.
Uzhavar Thirunal is a harvest festival celebrated in Tamil Nadu, India,
as part of the Pongal festivities. It is dedicated to honoring farmers
(uzhavar) and their contribution to agriculture. Uzhavar Thirunal usually
falls on January 16th or 17th each year.
https://en.wikipedia.org/wiki/Pongal_(festival)#Uzhavar_Thirunal
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.pongal_date(self._year), days_delta=+2
)
def _add_vaisakhi(self, name) -> date | None:
"""
Add Vaisakhi.
Vaisakhi is a major Sikh festival marking the Sikh New Year and the
founding of the Khalsa. It falls on April 13 or 14.
https://en.wikipedia.org/wiki/Vaisakhi
"""
return self._add_hindu_calendar_holiday(
name, self._hindu_calendar.vaisakhi_date(self._year)
)
|