Skip to content

Time ​

The Time namespace is the in-game clock.

The world runs on its own calendar, faster than real time and frozen while the game is paused. Anything with a due date, an age or a deadline should be measured against this rather than Date.now(): a report that takes two days to triage cannot take two real days, and a player who quits for a week should not come back to a world that resolved itself without them.

No permission required.

Available since SDK v0.23.0

The Time namespace requires @hotbunny/[email protected] or newer. Run npm install @hotbunny/hackhub-content-sdk@latest to update.

Import ​

typescript
import { Time } from "@hotbunny/hackhub-content-sdk";

Methods ​

Time.now() ​

Current in-game time, in milliseconds since the Unix epoch.

Returns: number

typescript
const submittedAt = Time.now();

Time.date() ​

Current in-game time as a Date, for formatting and calendar maths.

Returns: Date

typescript
const stamp = Time.date().toLocaleDateString();

Time.scale() ​

In-game milliseconds per real millisecond. 60 by default, so one real second is a game minute.

Returns: number

Time.isRunning() ​

false while the game is paused.

Returns: boolean

Time.duration(units) ​

Build an in-game duration in milliseconds from human units. Accepts minutes, hours and days.

Returns: number

typescript
const twoDays = Time.duration({ days: 2 });
const shift = Time.duration({ hours: 8, minutes: 30 });

Time.toRealMs(gameMs) ​

How much real time an in-game duration currently takes.

Returns: number

Time.toGameMs(realMs) ​

How much in-game time a real duration currently covers.

Returns: number

Why this exists ​

Real time and game time answer different questions, and using the wrong one produces content that either never resolves or resolves instantly.

Use Time for anything the fiction measures: deadlines, ages, "two days later". Use real time only for pacing something the player is watching right now, and prefer Scheduler over your own timers, because a timer dies with the session while a scheduled job survives a reload.

typescript
import { Time, Scheduler } from "@hotbunny/hackhub-content-sdk";

const submittedAt = Time.now();

// Due in two in-game days, whether or not the player stays in this session.
Scheduler.schedule("myPack.triage", { reportId: "R-1" }, { days: 2 });

HotBunny Interactive Entertainment Inc.