Creating an ITime Object

You can create an ITime object and initialize it to a number of seconds past or before midnight, or to a number of hours, minutes, and optionally seconds past midnight:

ITime Time1(33556),     // 09:19:16
                        // 33556 = 9 hours   (32400 seconds),
                        // 19 minutes (1140 seconds),
                        // 16 seconds (adds up to 33556)
      Time2(-33556),    // 14:40:44
                        // (9 hours, 19 minutes and
                        // 16 seconds BEFORE midnight)
      Time3(12,00),     // 12:00:00 (noon)
      Time4(3,3,3);     // 03:03:03

The constructors translate incorrect times into valid ITime objects using modulo arithmetic. For the seconds past midnight format, any number whose absolute value is greater than or equal to 86400 is divided by 86400, and the remainder is used to calculate the time. For the hours, minutes, and optional seconds format, excess minutes and seconds are added to the hours and minutes values, respectively, and if the hour exceeds 23 it is divided by 24 and the remainder is taken. For example:

ITime Time1(133556),     // 13:05:56 (13356-86400=47156 seconds
                         // after midnight)
      Time2(-133556),    // 10:54:04 (13356-86400=47156 seconds
                         // BEFORE midnight)
      Time3(10,119,60),  // 12:00:00 (noon) (10 hours
                         // plus 119 minutes plus 60 seconds)
      Time4(33,33);      // 09:33:00  (33 hours - 24 hours = 9 hours)