4.6.2 Method for decode-total-seconds

We define decode-total-seconds to convert in the other direction — from total seconds to hours, minutes, and seconds:

define method decode-total-seconds 	// 1
    (total-seconds :: <integer>)	// 2
 => (hours :: <integer>, minutes :: <integer>, seconds :: <integer>)	// 3
  let(total-minutes, seconds) = truncate/(total-seconds, 60);	// 4
  let(hours, minutes) = truncate/(total-minutes, 60);	// 5
  values(hours, minutes, seconds);	// 6
end method decode-total-seconds;	// 7

We can use decode-total-seconds to see the value of the total-seconds slot:

? decode-total-seconds(*your-time-of-day*.total-seconds);
8
30
59

The value declaration on line 3 specifies that decode-total-seconds returns three separate values: the hours, minutes, and seconds. This method illustrates how to return multiple values, and how to use let to initialize multiple local variables. We describe these techniques in Sections 4.6.3 and 4.6.4.