§9.7. Telling the time

Now that we have the time of day, we can of course use this value in room descriptions and the like:

The Clock Chamber is a room. "The dark chamber behind the clock face, a mill-room of gears which grind down the seconds. Through the glass you can see the reversed hands reading [the time of day]."

It seems odd, though, to read a precise numerical description of the time here: after all, it isn't a digital clock. A friendlier version would use:

say "[(time) in words]"

This text substitution produces the given time written out in English sentence form. For example:

"Through the glass you can see the reversed hands reading [the time of day in words]."

might produce

Through the glass you can see the reversed hands reading twenty to nine.

To reiterate an example which came up earlier, we could even work the time of day into the command prompt, which would lend the proper sense of urgency to a story played out against the clock:

When play begins: now the command prompt is "[time of day] >".


arrow-up.pngStart of Chapter 9: Time
arrow-left.pngBack to §9.6. The time of day
arrow-right.pngOnward to §9.8. Approximate times, lengths of time

Though Inform normally prints times in AM/PM terms, it stores the hours and minutes as 24-hour time; so, if we like, we can easily extract that information again thus:

paste.png "Situation Room"

The Situation Room is a room.

To say (relevant time - a time) as 24h time:
    let H be the hours part of relevant time;
    let M be the minutes part of relevant time;
    say "[if H is less than 10]0[end if][H][if M is less than 10]0[end if][M]".

When play begins:
    now the time of day is 6:09 PM;
    now the right hand status line is "[time of day as 24h time]".

Test me with "z".

*ExampleSituation Room
Printing the time of day in 24-hour time, as in military situations.

Though Inform normally prints times in AM/PM terms, it stores the hours and minutes as 24-hour time; so, if we like, we can easily extract that information again thus:

paste.png "Situation Room"

The Situation Room is a room.

To say (relevant time - a time) as 24h time:
    let H be the hours part of relevant time;
    let M be the minutes part of relevant time;
    say "[if H is less than 10]0[end if][H][if M is less than 10]0[end if][M]".

When play begins:
    now the time of day is 6:09 PM;
    now the right hand status line is "[time of day as 24h time]".

Test me with "z".

Though Inform normally prints times in AM/PM terms, it stores the hours and minutes as 24-hour time; so, if we like, we can easily extract that information again thus:

paste.png "Situation Room"

The Situation Room is a room.

To say (relevant time - a time) as 24h time:
    let H be the hours part of relevant time;
    let M be the minutes part of relevant time;
    say "[if H is less than 10]0[end if][H][if M is less than 10]0[end if][M]".

When play begins:
    now the time of day is 6:09 PM;
    now the right hand status line is "[time of day as 24h time]".

Test me with "z".