@tmlmobilidade/types
Version:
18 lines (17 loc) • 757 B
TypeScript
import { z } from 'zod';
/**
* UnixTimestamp, in this context, is a number that represents
* the number of milliseconds since the Unix epoch (1970-01-01T00:00:00Z).
*/
export type UnixTimestamp = number & {
__brand: 'UnixTimestamp';
};
export declare const UnixTimeStampSchema: z.ZodEffects<z.ZodNumber, UnixTimestamp, number>;
/**
* This function validates if a number is a valid Unix Timestamp, in milliseconds.
* It is assumed the number will always be greater than 10^10 (1e10) to ensure it is in milliseconds.
* Throws an error if the date is invalid.
* @param milliseconds - The number to be validated.
* @returns The given number as a UnixTimestamp.
*/
export declare function validateUnixTimestamp(milliseconds: number): UnixTimestamp;