The problem with previous code was that the hours and minutes are passed in as float to string.format.
string.format with "%02d" on float values rounds the values UP OR DOWN to the closest integer instead of rounding them ONLY DOWN to the closest integer.
The result of the previous code was that if the seconds value was greater than 30, the minutes value would be incorrectly incremented by 1.
Similarly, if the minute value was greater than 30, the hour value would be incorrectly incremented by 1.
The problem with previous code was that the hours and minutes are passed in as float to string.format. string.format with "%02d" on float values rounds the values UP OR DOWN to the closest integer instead of rounding them ONLY DOWN to the closest integer.
The result of the previous code was that if the seconds value was greater than 30, the minutes value would be incorrectly incremented by 1. Similarly, if the minute value was greater than 30, the hour value would be incorrectly incremented by 1.