API reference › @evolu/common › Time
Time representations, durations, and scheduling utilities.
Functions
| Function | Description |
|---|---|
| createTime | Creates a Time using Date.now(), performance, and globalThis.setTimeout. |
| durationToMillis | Converts a duration to milliseconds. |
| formatMillisAsClockTime | Formats Millis as local time in HH:MM:SS.mmm format. |
| formatMillisAsDuration | Formats Millis as a human-readable duration string. |
| millisToDateIso | Converts Millis to DateIso. |
| performanceDurationBetween | Returns the elapsed fractional milliseconds between two performance times. |
| saturateMillis | Converts a number to Millis, rounding to the nearest millisecond and saturating overflow at maxMillis. |
| testCreateTime | Creates a TestTime with controllable timers for testing. |
Interfaces
| Interface | Description |
|---|---|
| TestTime | Test Time with controllable timers. |
| TestTimeDep | - |
| Time | Time and timer operations. |
| TimeDep | - |
Type Aliases
| Type Alias | Description |
|---|---|
| Duration | DurationLiteral or Millis. |
| DurationLiteral | Duration literal Type with compile-time and runtime validation. |
| DurationLiteralDays | Days duration: "1d" to "6d" or "1.1d" to "6.9d". See DurationLiteral. |
| DurationLiteralHours | Hours duration: "1h" to "23h" or "1.1h" to "23.9h". See DurationLiteral. |
| DurationLiteralMilliseconds | Milliseconds duration: "1ms" to "999ms". See DurationLiteral. |
| DurationLiteralMinutes | Minutes duration: "1m" to "59m" or "1.1m" to "59.9m". See DurationLiteral. |
| DurationLiteralSeconds | Seconds duration: "1s" to "59s" or "1.1s" to "59.9s". See DurationLiteral. |
| DurationLiteralWeeks | Weeks duration: "1w" to "51w" or "1.1w" to "51.9w". See DurationLiteral. |
| DurationLiteralYears | Years duration: "1y" to "99y" or "1.1y" to "99.9y". See DurationLiteral. |
| Millis | Non-negative integer milliseconds used for timestamps and durations. |
| PerformanceDuration | Elapsed fractional milliseconds measured using PerformanceTime. |
| PerformanceTime | High-resolution milliseconds elapsed since PerformanceTimeOrigin. |
| PerformanceTimeOrigin | Unix epoch milliseconds used as the origin for PerformanceTime. |
| PositiveDuration | DurationLiteral or PositiveMillis. |
| PositiveMillis | Positive Millis value. |
| TimeoutId | Opaque type for timeout handles. |
Variables
| Variable | Description |
|---|---|
| DurationLiteral | Duration literal Type with compile-time and runtime validation. |
| DurationLiteralDays | Days duration: "1d" to "6d" or "1.1d" to "6.9d". See DurationLiteral. |
| DurationLiteralHours | Hours duration: "1h" to "23h" or "1.1h" to "23.9h". See DurationLiteral. |
| DurationLiteralMilliseconds | Milliseconds duration: "1ms" to "999ms". See DurationLiteral. |
| DurationLiteralMinutes | Minutes duration: "1m" to "59m" or "1.1m" to "59.9m". See DurationLiteral. |
| DurationLiteralSeconds | Seconds duration: "1s" to "59s" or "1.1s" to "59.9s". See DurationLiteral. |
| DurationLiteralWeeks | Weeks duration: "1w" to "51w" or "1.1w" to "51.9w". See DurationLiteral. |
| DurationLiteralYears | Years duration: "1y" to "99y" or "1.1y" to "99.9y". See DurationLiteral. |
| maxMillis | Maximum Millis value. |
| Millis | Non-negative integer milliseconds used for timestamps and durations. |
| minMillis | Minimum Millis value. |
| ms120fps | Frame budget at 120fps (8ms). |
| ms60fps | Frame budget at 60fps (16ms). |
| msLongTask | Long task threshold (50ms). |
| PositiveMillis | Positive Millis value. |