The Time Traveler

Python, 142 characters

R=raw_input
for i in' '*input():x,y,z,h,m,s=map(int,(R()+i+R()).split());t=input()+h*y*z+m*z+s;print'%02d:%02d:%02d'%((t/y/z-1)%x+1,t/z%y,t%z)

GolfScript - 50 chars

~](;7/{{~+.4$/\4$%])\}3*3<)@\or\+{100+`(;}%':'*n}%

The values (H/M/S) are collected by moving them to the front of the stack (])\). The hour 'underflow' at 0 is handled with or. Zero padding is handled with 100+`(;, although I suppose 0`\+-2> is the same length.


GolfScript 62 60 characters

Edit: I managed to get the array formerly stored in a to reside on the stack, it takes a little extra switching that way though so no major improvement.

~](\7/\{(~+[]\{.5$/@@5$%\+@@+}3*;\;(@or\+{'0'\+-2>}%':'*n@}*

62 version:

~](\7/\{[]:a;(~{+.4$/\4$%a+:a;}3*;;;a(@or\+{'0'\+-2>}%':'*n@}*
1______a2____3_b4_5___6__7____8__9__10_____11_________12____13

I'm sure it can be done a lot better, I just couldn't think of anything better.

1: Make an array of all input, pick off the first element, group the rest into blocks of 7.
a/13: Consume the first number from the input to run the loop that number of times.
2: Store an empty array in a.
3: Pick a block of 7 and expand it to 7 individual numbers.
b/8: Run a loop 3 times, once for each of seconds, minutes and hours.
4: Add the last two numbers together, for the first iteration that is seconds and time to shift, for the following it is minutes and hour with the overflow from the previous cycle. Make a second copy of the result.
5: Divide the copy by it's limit to produce the overflow and shift the result back one space.
6: Calculate the modulo of the previous division to produce a part of the result.
7: Add this part to the a array.
9: Remove the hour overflow and the second and minute limits from the stack.
10: Take the hour part of a, if it's zero replace it with the hour limit, put it back in the array.
11: For each element in a, place '0' in front, thus converting to string, and throw away everything but the last 2 characters.
12: Collapse the array into a single string delimited by ':', place a newline and shift the array containing the remaining jobs to the front of the stack, thus preparing for the next iteration.

Tags:

Code Golf