Example #1
0
    def test_valid_function(self):
        from pycalcal.wrappers import is_valid_chinese_date

        valid_dates = [chinese_date(2009, 5, 12, True),
                       chinese_date(1989, 5, 9, False),
                       chinese_date(1969, 6, 7, False)]
        for d in valid_dates:
            print("Validating:",d)
            self.assertTrue(is_valid_chinese_date(d))

        invalid_dates = [chinese_date(1989, 5, 9, True),
                         chinese_date(2010, 15, 3, False),
                         chinese_date(1903, 5, 30, False)]
        for d in invalid_dates:
            print("Validating:",d)
            self.assertFalse(is_valid_chinese_date(d))
Example #2
0
    def __init__(self, gregorian_date, chinese_date):
        if not (gregorian_date and chinese_date):
            raise ValueError
        if not is_valid_chinese_date(chinese_date):
            raise ValueError("Chinese date is not valid.")

        self.gregorian_date = gregorian_date
        self.chinese_date = chinese_date
        self._stem = get_stem(self.chinese_date)
        self._branch = get_branch(self.chinese_date)
Example #3
0
    def __init__(self, gregorian_date, chinese_date):
        if not (gregorian_date and chinese_date):
            raise ValueError
        if not is_valid_chinese_date(chinese_date):
            raise ValueError("Chinese date is not valid.")

        self.gregorian_date = gregorian_date
        self.chinese_date = chinese_date
        self._stem = get_stem(self.chinese_date)
        self._branch = get_branch(self.chinese_date)
Example #4
0
    def test_valid_function(self):
        from pycalcal.wrappers import is_valid_chinese_date

        valid_dates = [
            chinese_date(2009, 5, 12, True),
            chinese_date(1989, 5, 9, False),
            chinese_date(1969, 6, 7, False)
        ]
        for d in valid_dates:
            print("Validating:", d)
            self.assertTrue(is_valid_chinese_date(d))

        invalid_dates = [
            chinese_date(1989, 5, 9, True),
            chinese_date(2010, 15, 3, False),
            chinese_date(1903, 5, 30, False)
        ]
        for d in invalid_dates:
            print("Validating:", d)
            self.assertFalse(is_valid_chinese_date(d))