five-on-it / packages/shared/src/clock
packages/shared/src/clock
The room clock (GAME_DESIGN §5.4, §5.7): the time of day a room is played at, from a start time at a pace a game's rules set, and changed on the way by a mission. It is a pure function of the tick: a clock is where it stood at some tick (tick, minutes) and how fast it runs from there (pace, game minutes per real second: 1 is an hour a minute, a full day in 24 minutes; 0 stops it). So the server, every client and the AI agree on the hour with three numbers sent once, and again only when a mission sets the time or the pace (which re-anchors the clock at that tick). The clock keeps the game minutes since the room's first midnight (gameMinutesAt, never wrapped: day two's noon is 2160), so it only ever goes forward: set to a time of day it goes on to the next such time, and a skip (skipTime, "3 hours later") moves it on. The time of day is that modulo a day (clockAt): the schedules, the light and the weather (weather.ts) read it.
Times are minutes into the day, 0 (midnight) to just under DAY_MINUTES, and written HH:MM in documents.