using System;
public class TimeDiff
{
int seconds;
int minutes;
int hours;
public TimeDiff(int hours, int minutes, int seconds) {
this.hours = hours;
this.minutes = minutes;
this.seconds = seconds;
}
public static TimeDiff timeDifference(TimeDiff start, TimeDiff end) {
TimeDiff timediff = new TimeDiff(0, 0, 0);
if (start.seconds > end.seconds) {
end.minutes--;
end.seconds += 60;
}
timediff.seconds = end.seconds - start.seconds;
if (start.minutes > end.minutes) {
end.hours--;
end.minutes += 60;
}
timediff.minutes = end.minutes - start.minutes;
timediff.hours = end.hours - start.hours;
return timediff;
}
public static void Main(string[] args)
{
TimeDiff start = new TimeDiff(7, 11, 25);
TimeDiff end = new TimeDiff(11, 32, 17);
TimeDiff timediff = timeDifference(start, end);
Console.Write("{0:D}:{1:D}:{2:D} - ", start.hours, start.minutes, start.seconds);
Console.Write("{0:D}:{1:D}:{2:D} ", end.hours, end.minutes, end.seconds);
Console.Write("= {0:D}:{1:D}:{2:D}", timediff.hours, timediff.minutes, timediff.seconds);
}
}
/*
run:
7:11:25 - 11:31:77 = 4:20:52
*/