コード例 #1
0
ファイル: hijri.py プロジェクト: mohsenuss91/pyIslam
    def __init__(self, year, month, day):  # Constructor
        if isinstance(year, int):
            if year < 0:
                raise ValueError('year must be positive')
            else:
                self.year = year
        else:
            raise TypeError('year must be an int')

        if isinstance(month, int):
            if not (month in range(1, 13)):
                raise ValueError('month should be bitween 1 and 12')
            else:
                self.month = month
        else:
            raise TypeError('month must be an int')

        if isinstance(day, int):
            if not (month in range(1, 31)):
                raise ValueError('day should be bitween 1 and 30')
            else:
                self.day = day
        else:
            raise TypeError('day must be an int')

        self.__julian = hijriToJulianDay(self)
コード例 #2
0
    def __init__(self, year, month, day):  # Constructor
        if isinstance(year, int):
            if year < 0:
                raise ValueError('year must be positive')
            else:
                self.year = year
        else:
            raise TypeError('year must be an int')

        if isinstance(month, int):
            if not (month in range(1, 13)):
                raise ValueError('month should be bitween 1 and 12')
            else:
                self.month = month
        else:
            raise TypeError('month must be an int')

        if isinstance(day, int):
            if not (month in range(1, 31)):
                raise ValueError('day should be bitween 1 and 30')
            else:
                self.day = day
        else:
            raise TypeError('day must be an int')

        self.__julian = hijriToJulianDay(self)
コード例 #3
0
ファイル: hijri.py プロジェクト: mohsenuss91/pyIslam
 def __sub__(self, value):  # Return date dalta, self - value
     if isinstance(value, HijriDate):
         return timedelta(self.__julian - hijriToJulianDay(value))
     else:
         raise TypeError("unsupported operand type(s) for -: %s and %s"
                         % (str(type(self)), str(type(value))))
コード例 #4
0
 def __sub__(self, value):  # Return date dalta, self - value
     if isinstance(value, HijriDate):
         return timedelta(self.__julian - hijriToJulianDay(value))
     else:
         raise TypeError("unsupported operand type(s) for -: %s and %s" %
                         (str(type(self)), str(type(value))))