Stronger types for unix timestamps

This commit is contained in:
baldo 2022-07-18 12:55:19 +02:00
parent 217ed6ff20
commit c627e702ce
4 changed files with 22 additions and 9 deletions
server/types

View file

@ -293,8 +293,12 @@ export type MAC = {
};
export const isMAC = toIsNewtype<MAC>(isString);
export type UnixTimestampSeconds = number;
export type UnixTimestampMilliseconds = number;
export type UnixTimestampSeconds = number & { readonly __tag: unique symbol };
export type UnixTimestampMilliseconds = number & { readonly __tag: unique symbol };
export function toUnixTimestampSeconds(ms: UnixTimestampMilliseconds): UnixTimestampSeconds {
return Math.floor(ms) as UnixTimestampSeconds;
}
export type MonitoringToken = {
value: string;