Inform 7 Home Page / Documentation


§9.10. Calculating times

We will occasionally need to perform more complex calculations with time, and in order to do that, we have a way to convert the time of day to numbers. Thus the phrase "the minutes part of ..." takes a time and produces a number from 0 to 59; similarly "the hours part of ..." extracts a number from 0 to 23, using the twenty-four hour clock.

minutes part of (time) ... number

This phrase converts a time to a number, then takes the result mod 60, which in effect produces the number of minutes after the hours are thrown away. Example:

minutes part of 12:41 PM

produces 41.

hours part of (time) ... number

This phrase converts a time to a number, then divides the result by 60, which in effect produces the number of hours after minutes are thrown away. Example:

hours part of 8:21 AM

produces 8.

To go the other way, we can convert any number to a duration by writing "minutes" or "hours" after it. For instance:

paste.png The clock error is a number that varies. To thump the mechanism: now the clock error is a random number from -10 to 10.

The broken grandfather clock is in the Chamber. "An erratic grandfather clock seems to say it is [clock error minutes after the time of day]."

When play begins, thump the mechanism. Instead of attacking the broken clock: thump the mechanism; say "You thump the clock, which now reads [clock error minutes after the time of day].".

Note that "clock error" is a number, but "clock error minutes" is a time.


arrow-up.png Start of Chapter 9: Time
arrow-left.png Back to §9.9. Comparing and shifting times
arrow-right.png Onward to §9.11. Future events