def _populate(self, year): # New Year's Day name = "New Year's Day" self[date(year, 1, 1)] = name # Maundy Thursday name = "Maundy Thursday" self[easter(year) - rd(days=3)] = name # Good Friday name = "Good Friday" self[easter(year) - rd(days=2)] = name # Day of Valor name = "Day of Valor" self[date(year, 4, 9)] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Independence Day name = "Independence Day" self[date(year, 6, 12)] = name # Eid al-Fitr name = "Eid al-Fitr" islam_year = from_gregorian(year, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) self[date(year, m1, d1) - timedelta(days=1)] = name # Eid al-Adha, i.e., Feast of the Sacrifice name = "Feast of the Sacrifice" islam_year = from_gregorian(year, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) self[date(year, m, d)] = name # National Heroes' Day name = "National Heroes' Day" self[date(year, 8, 27)] = name # Bonifacio Day name = "Bonifacio Day" self[date(year, 11, 30)] = name # Christmas Day name = "Christmas Day" self[date(year, 12, 25)] = name # Rizal Day name = "Rizal Day" self[date(year, 12, 30)] = name
def _populate(self, year): # New Year's Day name = "New Year's Day" self[date(year, 1, 1)] = name # National Sovereignty and Children's Day name = "National Sovereignty and Children's Day " self[date(year, 4, 23)] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Commemoration of Atatürk, Youth and Sports Day name = u"Commemoration of Atatürk, Youth and Sports Day" self[date(year, 5, 19)] = name # Democracy and National Unity Day name = "Democracy and National Unity Day" self[date(year, 7, 15)] = name # Victory Day name = "Victory Day" self[date(year, 8, 30)] = name # Republic Day name = "Republic Day" self[date(year, 10, 29)] = name # Eid al-Fitr name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y, m, d = to_gregorian(islam_year, 10, 1) ds = date(y, m, d) - timedelta(days=1) if ds.year == year: self[ds] = name # Eid al-Adha, i.e., Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) if y == year: self[date(y, m, d)] = name
def _populate(self, year): # New Year's Day name = "New Year's Day" self[date(year, 1, 1)] = name # National Sovereignty and Children's Day name = "National Sovereignty and Children's Day " self[date(year, 4, 23)] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Commemoration of Atatürk, Youth and Sports Day name = "Commemoration of Atatürk, Youth and Sports Day" self[date(year, 5, 19)] = name # Democracy and National Unity Day name = "Democracy and National Unity Day" self[date(year, 7, 15)] = name # Victory Day name = "Victory Day" self[date(year, 8, 30)] = name # Republic Day name = "Republic Day" self[date(year, 10, 29)] = name # Eid al-Fitr name = "Eid al-Fitr" islam_year = from_gregorian(year, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) self[date(year, m1, d1) - timedelta(days=1)] = name # Eid al-Adha, i.e., Feast of the Sacrifice name = "Feast of the Sacrifice" islam_year = from_gregorian(year, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) self[date(year, m, d)] = name
def get_gre_date(year, Hmonth, Hday): """ Returns the gregorian dates within the gregorian year 'year' of all instances of islamic calendar 'Hmonth' and 'Hday'. Defaults to using the hijri-converter library if it is installed otherwise it uses the less-precise convertdate one (which is a requirement). """ try: from hijri_converter import convert Hyear = convert.Gregorian(year, 1, 1).to_hijri().datetuple()[0] gres = [convert.Hijri(y, Hmonth, Hday).to_gregorian() for y in range(Hyear - 1, Hyear + 2)] gre_dates = [date(*gre.datetuple()) for gre in gres if gre.year == year] return gre_dates except ImportError: import warnings from convertdate import islamic def warning_on_one_line(message, category, filename, lineno, file=None, line=None): return filename + ': ' + str(message) + '\n' warnings.formatwarning = warning_on_one_line warnings.warn("Islamic Holidays estimated using 'convertdate'" " package.") warnings.warn("For higher precision, install 'hijri-converter'" " package: pip install -U hijri-converter") warnings.warn("(see https://hijri-converter.readthedocs.io/ )") Hyear = islamic.from_gregorian(year, 1, 1)[0] gres = [islamic.to_gregorian(y, Hmonth, Hmonth) for y in range(Hyear - 1, Hyear + 2)] gre_dates = [date(*gre) for gre in gres if gre[0] == year] return gre_dates
def _populate(self, year): # New Year's Day name = "New Year's Day" self[date(year, 1, 1)] = name # Birthday of Prophet, Mawlid in India # 12th day of 3rd Islamic month name = "Birth of Prophet" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 11, 20)[0] y, m, d = to_gregorian(islam_year, 3, 12) if y == year: self[date(y, m, d)] = name # Chinese New Year name = "Chinese New Year" for offset in range(-1, 2, 1): ds = Converter.Lunar2Solar(Lunar(year + offset, 1, 1)).to_date() if ds.year == year: self[ds] = name # Tamil New Year # Note: it's not necessarily 04/14 # due to the local calendar # other possible dates are 04/13 and 04/15 name = "Tamil New Year" self[date(year, 4, 14)] = name # Good Friday name = "Good Friday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=2) if ds.year == year: self[ds] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Buddha's Birthday name = "Wesak Day" for offset in range(-1, 2, 1): ds = Converter.Lunar2Solar(Lunar(year + offset, 4, 15)).to_date() if ds.year == year: self[ds] = name # King's birthday # https://www.thestar.com.my/news/nation/2017/04/26/ # Before 2017: first Saturday of June # 2017-2021: last Saturday of July name = "King's birthday" if year < 2017: c = Calendar(firstweekday=MONDAY) monthcal = c.monthdatescalendar(year, 6) l1 = len(monthcal) saturdays = [] for i in range(l1): if monthcal[i][5].month == 6: saturdays.append(monthcal[i][5]) self[saturdays[0]] = name elif (year >= 2017) and (year <= 2021): c = Calendar(firstweekday=MONDAY) monthcal = c.monthdatescalendar(year, 7) l1 = len(monthcal) saturdays = [] for i in range(l1): if monthcal[i][5].month == 7: saturdays.append(monthcal[i][5]) self[saturdays[-1]] = name # Eid al-Fitr name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) y2, m2, d2 = to_gregorian(islam_year, 10, 2) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name # Malaysia Day name = "Malaysia Day" self[date(year, 9, 16)] = name # Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) if y == year: self[date(y, m, d)] = name # First Day of Muharram name = "First Day of Muharram" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 9, 11)[0] y, m, d = to_gregorian(islam_year + 1, 1, 1) if y == year: self[date(y, m, d)] = name # Christmas name = "Christmas Day" self[date(year, 12, 25)] = name
def _populate(self, year): # -------------------------------- # Three national days # Republic Day # Independence Day # Gandhi Jayanti # -------------------------------- # Republic Day name = "Republic Day" self[date(year, 1, 26)] = name # Independence Day name = "Independence Day" self[date(year, 8, 15)] = name # Gandhi Jayanti name = "Gandhi Jayanti" self[date(year, 10, 2)] = name # -------------------------------- # Hindu holidays # Diwali # Holi # -------------------------------- # Diwali, Holi # http://www.theholidayspot.com/diwali/calendar.htm # https://www.timeanddate.com/holidays/india/diwali?starty= # https://www.infoplease.com/calendar-holidays/major-holidays/ # https://www.learnreligions.com/when-is-holi-1770208 warning_msg = "We only support Diwali and Holi holidays from 2010 to 2030" warnings.warn(warning_msg, Warning) name1 = "Diwali" name2 = "Holi" if year == 2010: self[date(year, 12, 5)] = name1 self[date(year, 2, 28)] = name2 elif year == 2011: self[date(year, 10, 26)] = name1 self[date(year, 3, 19)] = name2 elif year == 2012: self[date(year, 11, 13)] = name1 self[date(year, 3, 8)] = name2 elif year == 2013: self[date(year, 11, 3)] = name1 self[date(year, 3, 26)] = name2 elif year == 2014: self[date(year, 10, 23)] = name1 self[date(year, 3, 17)] = name2 elif year == 2015: self[date(year, 11, 11)] = name1 self[date(year, 3, 6)] = name2 elif year == 2016: self[date(year, 10, 30)] = name1 self[date(year, 3, 24)] = name2 elif year == 2017: self[date(year, 10, 19)] = name1 self[date(year, 3, 13)] = name2 elif year == 2018: self[date(year, 11, 7)] = name1 self[date(year, 3, 2)] = name2 elif year == 2019: self[date(year, 10, 27)] = name1 self[date(year, 3, 21)] = name2 elif year == 2020: self[date(year, 11, 14)] = name1 self[date(year, 3, 9)] = name2 elif year == 2021: self[date(year, 11, 4)] = name1 self[date(year, 3, 28)] = name2 elif year == 2022: self[date(year, 10, 24)] = name1 self[date(year, 3, 18)] = name2 elif year == 2023: self[date(year, 10, 12)] = name1 self[date(year, 3, 7)] = name2 elif year == 2024: self[date(year, 11, 1)] = name1 self[date(year, 3, 25)] = name2 elif year == 2025: self[date(year, 10, 21)] = name1 self[date(year, 3, 14)] = name2 elif year == 2026: self[date(year, 11, 8)] = name1 self[date(year, 3, 3)] = name2 elif year == 2027: self[date(year, 10, 29)] = name1 self[date(year, 3, 22)] = name2 elif year == 2028: self[date(year, 10, 17)] = name1 self[date(year, 3, 11)] = name2 elif year == 2029: self[date(year, 11, 5)] = name1 self[date(year, 2, 28)] = name2 elif year == 2030: self[date(year, 10, 26)] = name1 self[date(year, 3, 19)] = name2 else: pass # -------------------------------- # Islamic holidays # Day of Ashura # Mawlid # Eid ul-Fitr # Eid al-Adha # -------------------------------- # Day of Ashura # 10th day of 1st Islamic month name = "Day of Ashura" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 10, 1)[0] y, m, d = to_gregorian(islam_year, 1, 10) if y == year: self[date(y, m, d)] = name # Mawlid, Birth of the Prophet # 12th day of 3rd Islamic month name = "Mawlid" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 11, 20)[0] y, m, d = to_gregorian(islam_year, 3, 12) if y == year: self[date(y, m, d)] = name # Eid ul-Fitr # 1st and 2nd day of 10th Islamic month name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) y2, m2, d2 = to_gregorian(islam_year, 10, 2) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name # Eid al-Adha, i.e., Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) if y == year: self[date(y, m, d)] = name # -------------------------------- # Christian holidays # New Year, Palm Sunday, # Maundy Thursday # Good Friday # Easter Sunday # Feast of Pentecost # Fest of St. Theresa of Calcutta # Feast of the Blessed Virgin # All Saints Day # All Souls Day # Christmas Day # Boxing Day # Feast of Holy Family # -------------------------------- # New Year's Day self[date(year, 1, 1)] = "New Year's Day" # Palm Sunday name = "Palm Sunday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=7) if ds.year == year: self[ds] = name # Maundy Thursday name = "Maundy Thursday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=3) if ds.year == year: self[ds] = name # Good Friday name = "Good Friday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=2) if ds.year == year: self[ds] = name # Easter Sunday name = "Easter Sunday" for offset in range(-1, 2, 1): ds = easter(year + offset) if ds.year == year: self[ds] = name # Feast of Pentecost name = "Feast of Pentecost" for offset in range(-1, 2, 1): ds = easter(year + offset) + rd(days=49) if ds.year == year: self[ds] = name # Fest of St. Theresa of Calcutta name = "Fest of St. Theresa of Calcutta" self[date(year, 9, 5)] = name # Feast of the Blessed Virgin name = "Feast of the Blessed Virgin" self[date(year, 9, 8)] = name # All Saints Day name = "All Saints Day" self[date(year, 11, 1)] = name # All Souls Day name = "All Souls Day" self[date(year, 11, 2)] = name # Christmas name = "Christmas Day" self[date(year, 12, 25)] = name # Boxing Day name = "Boxing Day" self[date(year, 12, 26)] = name # Feast of Holy Family name = "Feast of Holy Family" self[date(year, 12, 30)] = name
def _populate(self, year): # Fixed holidays # Christmas name = "Christmas" self[date(year, 1, 7)] = name # Revolution Day, after 2011 name = "Revolution Day 2011" if year <= 2011: self[date(year, 1, 25)] = name # Sinai Liberation Day, after 1982 name = "Sinai Liberation Day" if year <= 1982: self[date(year, 4, 25)] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Revolution Day name = "Sinai Liberation Day" self[date(year, 7, 23)] = name # Armed Forces Day name = "Armed Forces Day" self[date(year, 10, 6)] = name # Sham El Nessim # The Monday following Orthodox Easter name = "Sham El Nessim" for offset in range(-1, 2, 1): orthodox_easter = easter(year + offset, method=2) ds = orthodox_easter + timedelta(days=1) if ds.year == year: self[ds] = name # Islamic New Year name = "Islamic New Year" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 9, 11)[0] y, m, d = to_gregorian(islam_year + 1, 1, 1) if y == year: self[date(y, m, d)] = name # Birthday of Prophet, Mawlid in India # 12th day of 3rd Islamic month name = "Birth of Prophet" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 11, 20)[0] y, m, d = to_gregorian(islam_year, 3, 12) if y == year: self[date(y, m, d)] = name # Eid ul-Fitr # 1st and 2nd day of 10th Islamic month name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) y2, m2, d2 = to_gregorian(islam_year, 10, 2) y3, m3, d3 = to_gregorian(islam_year, 10, 3) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name if y3 == year: self[date(y3, m3, d3)] = name # Eid al-Adha, i.e., Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y1, m1, d1 = to_gregorian(islam_year, 12, 10) y2, m2, d2 = to_gregorian(islam_year, 12, 11) y3, m3, d3 = to_gregorian(islam_year, 12, 12) y4, m4, d4 = to_gregorian(islam_year, 12, 13) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name if y3 == year: self[date(y3, m3, d3)] = name if y4 == year: self[date(y4, m4, d4)] = name
def _populate(self, year): # New Year's Day name = "New Year's Day" self[date(year, 1, 1)] = name # Eid al-Fitr name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 9, 29) y2, m2, d2 = to_gregorian( islam_year, 9, 30) # Note: Ramadan day count is determined by Moon Sighting y3, m3, d3 = to_gregorian(islam_year, 10, 1) y4, m4, d4 = to_gregorian(islam_year, 10, 2) y5, m5, d5 = to_gregorian(islam_year, 10, 3) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name if y3 == year: self[date(y3, m3, d3)] = name if y4 == year: self[date(y4, m4, d4)] = name if y5 == year: self[date(y5, m5, d5)] = name # Day of Arafah name = "Day of Arafah" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 9) if y == year: self[date(y, m, d)] = name # Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y1, m1, d1 = to_gregorian(islam_year, 12, 10) y2, m2, d2 = to_gregorian(islam_year, 12, 11) y3, m3, d3 = to_gregorian(islam_year, 12, 12) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name if y3 == year: self[date(y3, m3, d3)] = name # Islamic New Year name = "Islamic New Year" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 9, 11)[0] y, m, d = to_gregorian(islam_year + 1, 1, 1) if y == year: self[date(y, m, d)] = name # Commemoration Day name = "Commemoration Day" self[date(year, 11, 30)] = name # National Day name = "National Day" self[date(year, 12, 2)] = name self[date(year, 12, 3)] = name
def _populate(self, year): # Kashmir Solidarity Day name = "Kashmir Solidarity Day" self[date(year, 2, 5)] = name # Pakistan Day name = "Pakistan Day" self[date(year, 3, 23)] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Independence Day name = "Independence Day" self[date(year, 8, 14)] = name # Iqbal Day name = "Iqbal Day" self[date(year, 11, 9)] = name # Christmas Day # Also birthday of PK founder name = "Christmas Day" self[date(year, 12, 25)] = name # Eid al-Adha, i.e., Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y1, m1, d1 = to_gregorian(islam_year, 12, 10) y2, m2, d2 = to_gregorian(islam_year, 12, 11) y3, m3, d3 = to_gregorian(islam_year, 12, 12) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name if y3 == year: self[date(y3, m3, d3)] = name # Eid al-Fitr name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) y2, m2, d2 = to_gregorian(islam_year, 10, 2) y3, m3, d3 = to_gregorian(islam_year, 10, 3) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name if y3 == year: self[date(y3, m3, d3)] = name # Mawlid, Birth of the Prophet # 12th day of 3rd Islamic month name = "Mawlid" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 11, 20)[0] y, m, d = to_gregorian(islam_year, 3, 12) if y == year: self[date(y, m, d)] = name # Day of Ashura # 10th and 11th days of 1st Islamic month name = "Day of Ashura" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 10, 1)[0] y1, m1, d1 = to_gregorian(islam_year, 1, 10) y2, m2, d2 = to_gregorian(islam_year, 1, 11) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name # Shab e Mairaj name = "Shab e Mairaj" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 4, 13)[0] y, m, d = to_gregorian(islam_year, 7, 27) if y == year: self[date(y, m, d)] = name # Defence Day name = "Defence Day" self[date(year, 9, 6)] = name # Death Anniversary of Quaid-e-Azam name = "Death Anniversary of Quaid-e-Azam" self[date(year, 9, 11)] = name
def _populate(self, year): # New Year's Day name = "New Year's Day" self[date(year, 1, 1)] = name # Maundy Thursday name = "Maundy Thursday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=3) if ds.year == year: self[ds] = name # Good Friday name = "Good Friday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=2) if ds.year == year: self[ds] = name # Day of Valor name = "Day of Valor" self[date(year, 4, 9)] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Independence Day name = "Independence Day" self[date(year, 6, 12)] = name # Eid al-Fitr name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y, m, d = to_gregorian(islam_year, 10, 1) ds = date(y, m, d) - timedelta(days=1) if ds.year == year: self[ds] = name # Eid al-Adha, i.e., Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) if y == year: self[date(y, m, d)] = name # National Heroes' Day name = "National Heroes' Day" self[date(year, 8, 27)] = name # Bonifacio Day name = "Bonifacio Day" self[date(year, 11, 30)] = name # Christmas Day name = "Christmas Day" self[date(year, 12, 25)] = name # Rizal Day name = "Rizal Day" self[date(year, 12, 30)] = name
def _populate(self, year): # New Year's Day if not self.observed and date(year, 1, 1).weekday() in WEEKEND: pass else: self[date(year, 1, 1)] = "New Year's Day" # Chinese New Year/ Spring Festival name = "Chinese New Year" for offset in range(-1, 2, 1): ds = LunarDate(year + offset, 1, 1).toSolarDate() if ds.year == year: self[ds] = name # Day of Silence / Nyepi # Note: # This holiday is determined by Balinese calendar, which is not currently # available. Only hard coded version of this holiday from 2009 to 2019 # is available. warning_msg = "We only support Nyepi holiday from 2009 to 2019" warnings.warn(warning_msg, Warning) name = "Day of Silence/ Nyepi" if year == 2009: self[date(year, 3, 26)] = name elif year == 2010: self[date(year, 3, 16)] = name elif year == 2011: self[date(year, 3, 5)] = name elif year == 2012: self[date(year, 3, 23)] = name elif year == 2013: self[date(year, 3, 12)] = name elif year == 2014: self[date(year, 3, 31)] = name elif year == 2015: self[date(year, 3, 21)] = name elif year == 2016: self[date(year, 3, 9)] = name elif year == 2017: self[date(year, 3, 28)] = name elif year == 2018: self[date(year, 3, 17)] = name elif year == 2019: self[date(year, 3, 7)] = name else: pass # Ascension of the Prophet name = "Ascension of the Prophet" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 3, 17)[0] y, m, d = to_gregorian(islam_year, 7, 27) if y == year: self[date(y, m, d)] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Ascension of Jesus Christ name = "Ascension of Jesus" for offset in range(-1, 2, 1): ds = easter(year + offset) + rd(days=+39) if ds.year == year: self[ds] = name # Buddha's Birthday name = "Buddha's Birthday" for offset in range(-1, 2, 1): ds = LunarDate(year + offset, 4, 15).toSolarDate() if ds.year == year: self[ds] = name # Pancasila Day, since 2017 if year >= 2017: name = "Pancasila Day" self[date(year, 6, 1)] = name # Eid al-Fitr name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) y2, m2, d2 = to_gregorian(islam_year, 10, 2) if y1 == year: self[date(y1, m2, d2)] = name if y2 == year: self[date(y2, m2, d2)] = name # Independence Day name = "Independence Day" self[date(year, 8, 17)] = name # Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) if y == year: self[date(y, m, d)] = name # Islamic New Year name = "Islamic New Year" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 9, 11)[0] y, m, d = to_gregorian(islam_year + 1, 1, 1) if y == year: self[date(y, m, d)] = name # Birth of the Prophet name = "Birth of the Prophet" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 11, 20)[0] y, m, d = to_gregorian(islam_year + 1, 3, 12) if y == year: self[date(y, m, d)] = name # Christmas self[date(year, 12, 25)] = "Christmas"
def _populate(self, year): # New Year's Day name = "New Year's Day" self[date(year, 1, 1)] = name # Birthday of Prophet, Mawlid in India # 12th day of 3rd Islamic month name = "Birth of Prophet" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 11, 20)[0] y, m, d = to_gregorian(islam_year, 3, 12) if y == year: self[date(y, m, d)] = name # Chinese New Year name = "Chinese New Year" for offset in range(-1, 2, 1): ds = LunarDate(year + offset, 1, 1).toSolarDate() if ds.year == year: self[ds] = name # Tamil New Year # Note: it's not necessarily 04/14 # due to the local calendar # other possible dates are 04/13 and 04/15 name = "Tamil New Year" self[date(year, 4, 14)] = name # Good Friday name = "Good Friday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=2) if ds.year == year: self[ds] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Buddha's Birthday name = "Wesak Day" for offset in range(-1, 2, 1): ds = LunarDate(year + offset, 4, 15).toSolarDate() if ds.year == year: self[ds] = name # King's birthday # https://www.thestar.com.my/news/nation/2017/04/26/ # Before 2017: first Saturday of June # 2017-2021: last Saturday of July name = "King's birthday" if year < 2017: c = Calendar(firstweekday=MONDAY) monthcal = c.monthdatescalendar(year, 6) l1 = len(monthcal) saturdays = [] for i in range(l1): if monthcal[i][5].month == 6: saturdays.append(monthcal[i][5]) self[saturdays[0]] = name elif (year >= 2017) and (year <= 2021): c = Calendar(firstweekday=MONDAY) monthcal = c.monthdatescalendar(year, 7) l1 = len(monthcal) saturdays = [] for i in range(l1): if monthcal[i][5].month == 7: saturdays.append(monthcal[i][5]) self[saturdays[-1]] = name # Eid al-Fitr name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) y2, m2, d2 = to_gregorian(islam_year, 10, 2) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name # Malaysia Day name = "Malaysia Day" self[date(year, 9, 16)] = name # Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) if y == year: self[date(y, m, d)] = name # First Day of Muharram name = "First Day of Muharram" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 9, 11)[0] y, m, d = to_gregorian(islam_year + 1, 1, 1) if y == year: self[date(y, m, d)] = name # Christmas name = "Christmas Day" self[date(year, 12, 25)] = name
def _populate(self, year): # -------------------------------- # Three national days # Republic Day # Independence Day # Gandhi Jayanti # -------------------------------- # Republic Day name = "Republic Day" self[date(year, 1, 26)] = name # Independence Day name = "Independence Day" self[date(year, 8, 15)] = name # Gandhi Jayanti name = "Gandhi Jayanti" self[date(year, 10, 2)] = name # -------------------------------- # Hindo holidays # Diwali # Holi # -------------------------------- # Diwali, Holi # http://www.theholidayspot.com/diwali/calendar.htm # https://www.timeanddate.com/holidays/india/diwali?starty= # https://www.infoplease.com/calendar-holidays/major-holidays/ warning_msg = "We only support Diwali and Holi holidays from 2010 to 2025" warnings.warn(warning_msg, Warning) name1 = "Diwali" name2 = "Holi" if year == 2010: self[date(year, 12, 5)] = name1 self[date(year, 2, 28)] = name2 elif year == 2011: self[date(year, 10, 26)] = name1 self[date(year, 3, 19)] = name2 elif year == 2012: self[date(year, 11, 13)] = name1 self[date(year, 3, 8)] = name2 elif year == 2013: self[date(year, 11, 3)] = name1 self[date(year, 3, 26)] = name2 elif year == 2014: self[date(year, 10, 23)] = name1 self[date(year, 3, 17)] = name2 elif year == 2015: self[date(year, 11, 11)] = name1 self[date(year, 3, 6)] = name2 elif year == 2016: self[date(year, 10, 30)] = name1 self[date(year, 3, 24)] = name2 elif year == 2017: self[date(year, 10, 19)] = name1 self[date(year, 3, 13)] = name2 elif year == 2018: self[date(year, 11, 7)] = name1 self[date(year, 3, 2)] = name2 elif year == 2019: self[date(year, 10, 27)] = name1 self[date(year, 3, 21)] = name2 elif year == 2020: self[date(year, 11, 14)] = name1 self[date(year, 3, 9)] = name2 elif year == 2021: self[date(year, 11, 4)] = name1 self[date(year, 3, 28)] = name2 elif year == 2022: self[date(year, 10, 24)] = name1 self[date(year, 3, 18)] = name2 elif year == 2023: self[date(year, 10, 12)] = name1 self[date(year, 3, 7)] = name2 elif year == 2024: self[date(year, 11, 1)] = name1 self[date(year, 3, 25)] = name2 elif year == 2025: self[date(year, 10, 21)] = name1 self[date(year, 3, 14)] = name2 else: pass # -------------------------------- # Islamic holidays # Day of Ashura # Mawlid # Eid ul-Fitr # Eid al-Adha # -------------------------------- # Day of Ashura # 10th day of 1st Islamic month name = "Day of Ashura" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 10, 1)[0] y, m, d = to_gregorian(islam_year, 1, 10) if y == year: self[date(y, m, d)] = name # Mawlid, Birth of the Prophet # 12th day of 3rd Islamic month name = "Mawlid" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 11, 20)[0] y, m, d = to_gregorian(islam_year, 3, 12) if y == year: self[date(y, m, d)] = name # Eid ul-Fitr # 1st and 2nd day of 10th Islamic month name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) y2, m2, d2 = to_gregorian(islam_year, 10, 2) if y1 == year: self[date(y1, m1, d1)] = name if y2 == year: self[date(y2, m2, d2)] = name # Eid al-Adha, i.e., Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) if y == year: self[date(y, m, d)] = name # -------------------------------- # Christian holidays # New Year, Palm Sunday, # Maundy Thursday # Good Friday # Easter Sunday # Feast of Pentecost # Fest of St. Theresa of Calcutta # Feast of the Blessed Virgin # All Saints Day # All Souls Day # Christmas Day # Boxing Day # Feast of Holy Family # -------------------------------- # New Year's Day self[date(year, 1, 1)] = "New Year's Day" # Palm Sunday name = "Palm Sunday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=7) if ds.year == year: self[ds] = name # Maundy Thursday name = "Maundy Thursday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=3) if ds.year == year: self[ds] = name # Good Friday name = "Good Friday" for offset in range(-1, 2, 1): ds = easter(year + offset) - rd(days=2) if ds.year == year: self[ds] = name # Easter Sunday name = "Easter Sunday" for offset in range(-1, 2, 1): ds = easter(year + offset) if ds.year == year: self[ds] = name # Feast of Pentecost name = "Feast of Pentecost" for offset in range(-1, 2, 1): ds = easter(year + offset) + rd(days=49) if ds.year == year: self[ds] = name # Fest of St. Theresa of Calcutta name = "Fest of St. Theresa of Calcutta" self[date(year, 9, 5)] = name # Feast of the Blessed Virgin name = "Feast of the Blessed Virgin" self[date(year, 9, 8)] = name # All Saints Day name = "All Saints Day" self[date(year, 11, 1)] = name # All Souls Day name = "All Souls Day" self[date(year, 11, 2)] = name # Christmas name = "Christmas Day" self[date(year, 12, 25)] = name # Boxing Day name = "Boxing Day" self[date(year, 12, 26)] = name # Feast of Holy Family name = "Feast of Holy Family" self[date(year, 12, 30)] = name
def _populate(self, year): # New Year's Day if not self.observed and date(year, 1, 1).weekday() in WEEKEND: pass else: self[date(year, 1, 1)] = "New Year's Day" # Chinese New Year/ Spring Festival name = "Chinese New Year" for offset in range(-1, 2, 1): ds = Converter.Lunar2Solar(Lunar(year + offset, 1, 1)).to_date() if ds.year == year: self[ds] = name # Day of Silence / Nyepi # Note: # This holiday is determined by Balinese calendar, which is not currently # available. Only hard coded version of this holiday from 2009 to 2019 # is available. warning_msg = "We only support Nyepi holiday from 2009 to 2019" log.warning(warning_msg) name = "Day of Silence/ Nyepi" if year == 2009: self[date(year, 3, 26)] = name elif year == 2010: self[date(year, 3, 16)] = name elif year == 2011: self[date(year, 3, 5)] = name elif year == 2012: self[date(year, 3, 23)] = name elif year == 2013: self[date(year, 3, 12)] = name elif year == 2014: self[date(year, 3, 31)] = name elif year == 2015: self[date(year, 3, 21)] = name elif year == 2016: self[date(year, 3, 9)] = name elif year == 2017: self[date(year, 3, 28)] = name elif year == 2018: self[date(year, 3, 17)] = name elif year == 2019: self[date(year, 3, 7)] = name else: pass # Ascension of the Prophet name = "Ascension of the Prophet" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 3, 17)[0] y, m, d = to_gregorian(islam_year, 7, 27) if y == year: self[date(y, m, d)] = name # Labor Day name = "Labor Day" self[date(year, 5, 1)] = name # Ascension of Jesus Christ name = "Ascension of Jesus" for offset in range(-1, 2, 1): ds = easter(year + offset) + rd(days=+39) if ds.year == year: self[ds] = name # Buddha's Birthday name = "Buddha's Birthday" for offset in range(-1, 2, 1): ds = Converter.Lunar2Solar(Lunar(year + offset, 4, 15)).to_date() if ds.year == year: self[ds] = name # Pancasila Day, since 2017 if year >= 2017: name = "Pancasila Day" self[date(year, 6, 1)] = name # Eid al-Fitr name = "Eid al-Fitr" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 6, 15)[0] y1, m1, d1 = to_gregorian(islam_year, 10, 1) y2, m2, d2 = to_gregorian(islam_year, 10, 2) if y1 == year: self[date(y1, m2, d2)] = name if y2 == year: self[date(y2, m2, d2)] = name # Independence Day name = "Independence Day" self[date(year, 8, 17)] = name # Feast of the Sacrifice name = "Feast of the Sacrifice" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 8, 22)[0] y, m, d = to_gregorian(islam_year, 12, 10) if y == year: self[date(y, m, d)] = name # Islamic New Year name = "Islamic New Year" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 9, 11)[0] y, m, d = to_gregorian(islam_year + 1, 1, 1) if y == year: self[date(y, m, d)] = name # Birth of the Prophet name = "Birth of the Prophet" for offset in range(-1, 2, 1): islam_year = from_gregorian(year + offset, 11, 20)[0] y, m, d = to_gregorian(islam_year + 1, 3, 12) if y == year: self[date(y, m, d)] = name # Christmas self[date(year, 12, 25)] = "Christmas"
def convertIslamicDateOperator( year, month, day ): return RPNDateTime( *islamic.to_gregorian( int( year ), int( month ), int( day ) ), dateOnly = True )
def convertIslamicDate( year, month, day ): return RPNDateTime( *islamic.to_gregorian( real_int( year ), real_int( month ), real_int( day ) ) )