def __sub__(self, other): if isinstance(other, timedelta): new_date = self.gregorian_date - other cdate = chinese_from_gregorian(new_date) return ChineseDate(new_date, cdate) else: return self.gregorian_date - other
def __sub__(self, other): if isinstance(other, timedelta): new_date = self.gregorian_date - other cdate = chinese_from_gregorian(new_date) return ChineseDate(new_date, cdate) else: return self.gregorian_date - other
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 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_gregorian(cls, year, month, day): """Return an instance of ChineseDate. Based on the given date in the Gregorian calendar. The year parameter must be within [datetime.MINYEAR, datetime.MAXYEAR] """ gdate = date(year, month, day) cdate = chinese_from_gregorian(gdate) return cls(gdate, cdate)
def from_gregorian(cls, year, month, day): ''' Returns an instance of ChineseDate, based on the given date in the Gregorian calendar. The year parameter must be within [datetime.MINYEAR, datetime.MAXYEAR] ''' gdate = date(year, month, day) cdate = chinese_from_gregorian(gdate) return cls(gdate, cdate)
def __add__(self, other): new_date = self.gregorian_date + other cdate = chinese_from_gregorian(new_date) return ChineseDate(new_date, cdate)
def fromordinal(cls, ordinal): gdate = date.fromordinal(ordinal) cdate = chinese_from_gregorian(gdate) return cls(gdate, cdate)
def fromtimestamp(cls, timestamp): gdate = date.fromtimestamp(timestamp) cdate = chinese_from_gregorian(gdate) return cls(gdate, cdate)
def today(cls): gdate = date.today() cdate = chinese_from_gregorian(gdate) return cls(gdate, cdate)
def __add__(self, other): new_date = self.gregorian_date + other cdate = chinese_from_gregorian(new_date) return ChineseDate(new_date, cdate)
def fromordinal(cls, ordinal): gdate = date.fromordinal(ordinal) cdate = chinese_from_gregorian(gdate) return cls(gdate, cdate)
def fromtimestamp(cls, timestamp): gdate = date.fromtimestamp(timestamp) cdate = chinese_from_gregorian(gdate) return cls(gdate, cdate)
def today(cls): gdate = date.today() cdate = chinese_from_gregorian(gdate) return cls(gdate, cdate)