Compute the time from what? Are you converting something to H,M,S, or are you counting time? If the latter it's just a case of incrementing three variables and wrapping round to zero when each reaches an appropriate value.