Exemple #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
Exemple #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
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #7
0
 def __add__(self, other):
     new_date = self.gregorian_date + other
     cdate = chinese_from_gregorian(new_date)
     return ChineseDate(new_date, cdate)
Exemple #8
0
 def fromordinal(cls, ordinal):
     gdate = date.fromordinal(ordinal)
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Exemple #9
0
 def fromtimestamp(cls, timestamp):
     gdate = date.fromtimestamp(timestamp)
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Exemple #10
0
 def today(cls):
     gdate = date.today()
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Exemple #11
0
 def __add__(self, other):
     new_date = self.gregorian_date + other
     cdate = chinese_from_gregorian(new_date)
     return ChineseDate(new_date, cdate)
Exemple #12
0
 def fromordinal(cls, ordinal):
     gdate = date.fromordinal(ordinal)
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Exemple #13
0
 def fromtimestamp(cls, timestamp):
     gdate = date.fromtimestamp(timestamp)
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)
Exemple #14
0
 def today(cls):
     gdate = date.today()
     cdate = chinese_from_gregorian(gdate)
     return cls(gdate, cdate)