The 24-hour clock is the convention of time keeping in which the day runs from midnight to midnight and is divided into 24 hours, indicated by the hours passed since midnight, from 0 to 23. This system is the most commonly used time notation in the world today, and is the international standard notation (ISO 86011) for time of day.
A time of day is written in the 24-hour notation in the form hh:mm:ss (for example, 01:23:45), where hh (00 to 23) is the number of full hours that have passed since midnight, mm (00 to 59) is the number of full minutes that have passed since the last full hour, and ss (00 to 59) is the number of full seconds that have passed since the last full minute. A leading zero is added for numbers that are less than 10. In the 24-hour time notation, the day begins at midnight (00:00:00) and the last second of the day falls at 23:59:59.
Define a class Clock that can be used to represent 24-hour clocks in Python. The class Clock must at least support the following methods:
An initialisation method that has three optional parameters: hours, minutes and seconds. These parameters respectively give the number of full hours $$h$$ ($$0 \leq h < 24$$) that have passed since midnight, the number of full minutes $$m$$ ($$0 \leq m < 60$$) that have passed since the last full hour, and the number of full seconds $$s$$ ($$0 \leq s < 60$$) that have passed since the last full minute. All parameters have zero as their default value. The initial time of the clock needs to be set based on the arguments that are passed to the initialisation method.
A method __repr__ that returns a string representation of the object, corresponding to the Python expression that can be used to create a 24-hours clock that has the same time settings as the current clock. The string that is returned must thus have the format Clock(h, m, s), where $$h$$ ($$0 \leq h < 24$$) represents the number of full hours since midnight, $$m$$ ($$0 \leq m < 60$$) represents the number of full minutes since the last full hour, and $$s$$ ($$0 \leq s < 60$$) represents the number of full seconds since the last full minute.
A method __str__ that returns a string representation of the object in the format hh:mm:ss as described in the introduction.
A method set that has three optional parameters: hours, minutes and seconds. These parameters have the same semantics and default values as the corresponding parameters of the initialisation method. The new time of the clock needs to be set based on the arguments that are passed to the method.
A method forward that has three optional parameters: hours, minutes and seconds. The arguments passed to these parameters respectively indicate the number of hours, minutes and seconds the clock needs to be set forward. In doing so, the method must take into account that after the last second of the day (23:59:59), the clock resets to 00:00:00.
>>> clock = Clock()
>>> clock
Clock(0, 0, 0)
>>> print(clock)
00:00:00
>>> clock.set(hours=7, minutes=5, seconds=41)
>>> clock
Clock(7, 5, 41)
>>> print(clock)
07:05:41
>>> clock.forward(minutes=57, seconds=39)
>>> print(clock)
08:03:20
>>> clock.forward(hours=20, minutes=8, seconds=48)
>>> print(clock)
04:12:08