What I came up with was very much like what Laroquod has; the main difference is that instead of comparing times, I just compared hours. The plus is that it gets around the 4:00 problem.
The minus is that, if you increase the time of day past midnight (but not if you set it to a specific time), it will register as an hour past 24 for that turn (although the time of day displays correctly). The next turn it will correct itself and increment the day. Any ideas why it would do this?
I called the date “current day, current month, current year” rather than “day, month, year” to allow for the inclusion of other dates (say, a character’s birthday).
[code]Month is a kind of value.
The months are January, February, March, April, May, June, July, August, September, October, November, and December.
A month can be short, leap, medium, or long. A month is usually long.
February is short.
April, June, September, and November are medium.
The current day is a number that varies.
The current month is a month that varies.
The current year is a number that varies.
The current day is 31.
The current month is August.
The current year is 2010.
The time of day is 8:00 PM.
The current hour is a number that varies.
The last hour is a number that varies.
The current hour is 20.
The last hour is 20.
Every turn (this is the time increment rule):
now the last hour is the current hour;
now the current hour is the hours part of the time of day;
if the current hour < the last hour:
increment the current day;
if the current month is short:
Let X be the current day - 28;
if X > 0:
increment the current month;
now the current day is X;
if the current month is medium:
Let X be the current day - 30;
if X > 0:
increment the current month;
now the current day is X;
if the current month is long:
Let X be the current day - 31;
if X > 0:
if the current month is December:
now the current month is January;
increment the current year;
otherwise:
increment the current month;
now the current day is X.
The Bedroom is a room. “The perpetual mess serves as a deterrent to adults.”
The clock is in the bedroom. “A clock hangs on the wall. Each tick brings with it a foreboding sense of doom.”
Instead of examining the clock:
say “The current hour is [current hour].”;
say “It’s [the time of day].”
The calendar is in the bedroom. “There’s also a calendar, as if you needed to be reminded.”
Instead of examining the calendar:
say “It’s [the current month] [the current day], [the current year].”;
if the current month is September:
if the current day is 1:
if the current hour > 8:
say “[first time]Oh no! You’ve missed the first day of school![only]”
Instead of waiting:
say “You procrastinate.”;
let X be a random number between 30 and 120;
increase the time of day by X minutes.
Instead of sleeping:
say “You go back to sleep.”;
now the time of day is a random time.
Test calendar with “examine clock / examine calendar / sleep / examine clock / examine calendar / wait / examine clock / examine calendar / sleep / sleep / examine calendar”.[/code]
I was trying to get a properly formatted date to work, but I couldn’t figure out how to make the numerical month and the named month be recognized as the same thing.