def __init__(self, time_range):
        """
        Constructor from timerange string.
        The time range format is HH:MM,HH:MM.
        """
        try:
            start_time, end_time = time_range.split(',')
        except ValueError:
            raise ValueError("%r is not a time range specification, use: HH:MM,HH:MM")

        self.start_time = datetime.datetime.strptime(start_time.strip(), '%H:%M').time()
        self.end_time = datetime.datetime.strptime(end_time.strip(), '%H:%M').time()
        if self.start_time == self.end_time:
            raise ValueError("times must be differents!")

        self.h1 = self.start_time.hour
        self.m1 = self.start_time.minute
        self.h2 = self.end_time.hour
        self.m2 = self.end_time.minute
def __init__ ( self , time_range ) : try : start_time , end_time = time_range . split ( ',' ) except ValueError : raise ValueError ( "%r is not a time range specification, use: HH:MM,HH:MM" ) self . start_time = datetime . datetime . strptime ( start_time . strip ( ) , '%H:%M' ) . time ( ) self . end_time = datetime . datetime . strptime ( end_time . strip ( ) , '%H:%M' ) . time ( ) if self . start_time == self . end_time : raise ValueError ( "times must be differents!" ) self . h1 = self . start_time . hour self . m1 = self . start_time . minute self . h2 = self . end_time . hour self . m2 = self . end_time . minute
Constructor from timerange string.
        The time range format is HH:MM,HH:MM.