@tmlmobilidade/types
Version:
33 lines (32 loc) • 1 kB
TypeScript
import { z } from 'zod';
/**
* Parses an operational HH:MM.
*
* Rules:
* - minimum is 04:00
* - maximum is 29:59
* - minutes must be 00–59
* - hour must be at least 2 digits in stored format
*/
export declare function operationalHhmmToMinutes(hhmm: string, ignoreStartHour?: boolean): number;
/**
* Converts common typed time formats into strict HH:MM.
*
* Examples:
* - "800" -> "08:00"
* - "0800" -> "08:00"
* - "2200" -> "22:00"
* - "2600" -> "26:00"
* - "8:00" -> "08:00"
* - "26:00" -> "26:00"
*
* Returns null if it cannot normalize safely.
*/
export declare function normalizeOperationalHhmmInput(value: string): null | string;
export declare const HHMMSchema: z.ZodBranded<z.ZodEffects<z.ZodString, string, string>, "HHMM">;
export type HHMM = z.infer<typeof HHMMSchema>;
/**
* Runtime-safe creator (validates + brands)
*/
export declare const hhmm: (value: string) => HHMM;
export declare function timeToMinutes(time: HHMM | string, ignoreStartHour?: boolean): number;