China: optimizations
@@ -30,35 +30,38 @@ class China(HolidayBase):
HolidayBase.__init__(self, **kwargs)
def _populate(self, year):
- # New Year's Day
- if year > 1949:
+ if year <= 1949:
+ return
+
self[date(year, JAN, 1)] = "New Year's Day"
- self[date(year, MAY, 1)] = "Labour Day"
- hol_date = self.cnls.lunar_n_y_date(year)
- self[hol_date] = "Chinese New Year (Spring Festival)"
- self[hol_date + rd(days=+1)] = "Chinese New Year (Spring Festival)"
- self[date(year, OCT, 1)] = "National Day"
- self[date(year, OCT, 2)] = "National Day"
- if year > 2007:
+
+ name = "Labour Day"
+ dt = date(year, MAY, 1)
+ self[dt] = name
+ if 2000 <= year <= 2007:
+ self[dt + rd(days=+1)] = name
+ self[dt + rd(days=+2)] = name
+
+ name = "Chinese New Year (Spring Festival)"
+ dt = self.cnls.lunar_n_y_date(year)
+ self[dt] = name
+ self[dt + rd(days=+1)] = name
+ if 2008 <= year <= 2013:
+ self[dt + rd(days=-1)] = name
+ else:
+ self[dt + rd(days=+2)] = name
+
+ name = "National Day"
+ dt = date(year, OCT, 1)
+ self[dt] = name
+ self[dt + rd(days=+1)] = name
+ if year >= 2000:
+ self[dt + rd(days=+2)] = name
+
+ if year >= 2008:
self[date(year, APR, 5)] = "Tomb-Sweeping Day"
self[self.cnls.lunar_to_gre(year, 5, 5)] = "Dragon Boat Festival"
self[self.cnls.lunar_to_gre(year, 8, 15)] = "Mid-Autumn Festival"
- if (year > 1999) and (year <= 2007):
- self[date(year, MAY, 2)] = "Labour Day"
- self[date(year, MAY, 3)] = "Labour Day"
- if year > 1999:
- self[date(year, OCT, 3)] = "National Day"
- if (year > 1999) and (year <= 2007):
- self[date(year, MAY, 2)] = "Labour Day"
- self[date(year, MAY, 3)] = "Labour Day"
- if (year > 2007) and (year <= 2013):
- self[
- self.cnls.lunar_to_gre(year, 1, 1) + rd(days=-1)
- ] = "Chinese New Year (Spring Festival)"
- elif year > 1949:
- self[
- self.cnls.lunar_to_gre(year, 1, 3)
- ] = "Chinese New Year (Spring Festival)"
class CN(China):
