Let's look at what your code does for input of 3601

minute, hour, and second will have the values 60, 1, and 0 respectively, but from your description they should have the value 0, 1, and 1...