예제 #1
0
 def __init__(self, strperiod):
     period = strperiod.split('.')
     if len(period) == 2:
         unit_count = int(period[0])
         time_unit = period[1].upper()
     else:
         raise PeriodTypeError
     if time_unit not in self.periods.keys():
         raise PeriodTypeError(period=time_unit)
     self.unit = time_unit
     self.count = unit_count
예제 #2
0
    def __init__(self, str_period):
        period = str_period.split('.')
        if len(period) == 2:
            unit_count = int(period[0])
            time_unit = period[1].upper()
        else:
            raise PeriodTypeError
        if time_unit not in self.periods:
            raise PeriodTypeError(period=time_unit)

        self._type = time_unit
        self._length = unit_count