def main(): print('title,start,end,country') for g in step.generate_gregorian(core.from_gregorian(2019, 1, 1)): if g.year >= 2119: break hd = holiday(g) if hd: date = '%04d-%02d-%02d' % (g.year, g.month, g.day_of_month) print('%s,%s,%s,FI' % (hd, date, date))
def year_months(year): months = 12 * [0] easter = core.easter(year) for g in step.generate_gregorian(core.from_gregorian(year, 1, 1)): if g.year != year: break if workday(g, easter): months[g.month - 1] += 1 return months
def test_exhaustive(self): base = 730791 for g, w, d in islice(zip(step.generate_gregorian(base), step.generate_iso_week_date(base), count(base)), 0, 146097): self.assertEqual(g.day, d) self.assertEqual(g.day, w.day) self.assertEqual(g.weekday + 1, w.day_of_week) self.assertEqual(core.to_gregorian(g.day), (g.year, g.month, g.day_of_month)) self.assertEqual(core.from_gregorian(g.year, g.month, g.day_of_month), g.day) self.assertEqual(core.to_iso_week_date(w.day), (w.year, w.week, w.day_of_week)) self.assertEqual(core.from_iso_week_date(w.year, w.week, w.day_of_week), w.day)
def is_gregorian(yg, mg, dg): """Check if (year, month, day) is a valid Gregorian date.""" return core.to_gregorian(core.from_gregorian(yg, mg, dg)) == (yg, mg, dg)
def year_type(year): leap = year % 400 == 0 or year % 4 == 0 and year % 100 != 0 easter = core.easter(year) - core.from_gregorian(year, 3, 22) return 2 * easter + +leap