Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 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
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
 def __add__(self, other):
     new_date = self.gregorian_date + other
     cdate = chinese_from_gregorian(new_date)
     return ChineseDate(new_date, cdate)
Ejemplo n.º 8
0
 def fromordinal(cls, ordinal):
     gdate = date.fromordinal(ordinal)
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Ejemplo n.º 9
0
 def fromtimestamp(cls, timestamp):
     gdate = date.fromtimestamp(timestamp)
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Ejemplo n.º 10
0
 def today(cls):
     gdate = date.today()
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Ejemplo n.º 11
0
 def __add__(self, other):
     new_date = self.gregorian_date + other
     cdate = chinese_from_gregorian(new_date)
     return ChineseDate(new_date, cdate)
Ejemplo n.º 12
0
 def fromordinal(cls, ordinal):
     gdate = date.fromordinal(ordinal)
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Ejemplo n.º 13
0
 def fromtimestamp(cls, timestamp):
     gdate = date.fromtimestamp(timestamp)
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Ejemplo n.º 14
0
 def today(cls):
     gdate = date.today()
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)