def test_conversions(self): from pycalcal.wrappers import gregorian_from_chinese, chinese_from_gregorian moon_landing_chinese = chinese_date(1969, 6, 7, False) self.assertEqual(chinese_from_gregorian(self.moon_landing),\ moon_landing_chinese) july_fourth_greg = date(2009, 7, 4) self.assertEqual(gregorian_from_chinese(self.july_fourth),\ july_fourth_greg)
def from_chinese(cls, chinese_year, chinese_month, chinese_day, is_leap_month=False): """Return an instance of ChineseDate. Based on the given date in the Chinese calendar. A ChineseDate is represented by - Year: Same as the Grogorian year. - Month: An integer between 1 and 12 inclusive. - Day: An integer between 1 and 30 inclusive. - is_leap_month: A boolean representing whether the date is in the leap month. In the Chinese calendar, the leap month shares the same number as the original month. For example, the year 2009 has the following months: 1, 2, 3, 4, 5, 5*, 6, 7, 8, 9, 10, 11, 12; 5* being the leap month. """ cdate = CDate(chinese_year, chinese_month, chinese_day, is_leap_month) gdate = gregorian_from_chinese(cdate) return cls(gdate, cdate)
def from_chinese(cls, chinese_year, chinese_month, chinese_day, is_leap_month=False): ''' Returns an instance of ChineseDate, based on the given date in the Chinese calendar. A ChineseDate is represented by - Year: Same as the Grogorian year. - Month: An integer between 1 and 12 inclusive. - Day: An integer between 1 and 30 inclusive. - is_leap_month: A boolean representing whether the date is in the leap month. In the Chinese calendar, the leap month shares the same number as the original month. For example, the year 2009 has the following months: 1, 2, 3, 4, 5, 5*, 6, 7, 8, 9, 10, 11, 12; 5* being the leap month. ''' cdate = CDate(chinese_year, chinese_month, chinese_day, is_leap_month) gdate = gregorian_from_chinese(cdate) return cls(gdate, cdate)