mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 13:23:35 +00:00
feat: create branded types to determine different handling of time
This commit is contained in:
committed by
Carlos Valente
parent
168d7103b1
commit
e8f159d894
@@ -0,0 +1,15 @@
|
||||
declare const __brand: unique symbol;
|
||||
type Brand<B> = { [__brand]: B };
|
||||
type Branded<T, B> = T & Brand<B>;
|
||||
|
||||
/** A timestamp in milliseconds from epoch */
|
||||
export type Instant = Branded<number, 'instant'>;
|
||||
|
||||
/** A timestamp of milliseconds since midnight today in the set timezone */
|
||||
export type TimeOfDay = Branded<number, 'time-of-day'>;
|
||||
|
||||
/** A duration of milliseconds */
|
||||
export type Duration = Branded<number, 'duration'>;
|
||||
|
||||
/** A day count integer */
|
||||
export type Day = Branded<number, 'day'>;
|
||||
@@ -20,6 +20,9 @@ export type { RundownEntries, Rundown, ProjectRundowns } from './definitions/cor
|
||||
export { TimeStrategy } from './definitions/TimeStrategy.type.js';
|
||||
export { TimerType } from './definitions/TimerType.type.js';
|
||||
|
||||
// ---> Core
|
||||
export type { Day, Duration, Instant, TimeOfDay } from './definitions/core/Temporal.js';
|
||||
|
||||
// ---> Report
|
||||
export type { OntimeReport, OntimeEventReport } from './definitions/core/Report.type.js';
|
||||
|
||||
@@ -125,7 +128,7 @@ export {
|
||||
isOntimeAction,
|
||||
isTimerLifeCycle,
|
||||
} from './utils/guards.js';
|
||||
export type { MaybeNumber, MaybeString } from './utils/utils.type.js';
|
||||
export type { Maybe, MaybeNumber, MaybeString } from './utils/utils.type.js';
|
||||
|
||||
// Colour
|
||||
export type { RGBColour } from './definitions/Colour.type.js';
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
export type MaybeNumber = number | null;
|
||||
export type MaybeString = string | null;
|
||||
|
||||
export type Maybe<T> = T | null;
|
||||
|
||||
Reference in New Issue
Block a user