ts-type-forge
    Preparing search index...

    Type Alias HoursEnum

    HoursEnum: Index<24>

    Represents the hours in a day using 24-hour format. A union of integer literals from 0 (midnight) to 23 (11 PM).

    Uses the international standard 24-hour time format where:

    • 0 represents midnight (00:00)
    • 12 represents noon (12:00)
    • 23 represents 11 PM (23:00)
    const formatHour = (hour: HoursEnum): string =>
    hour.toString().padStart(2, '0');

    const is12HourFormat = (hour: HoursEnum): string =>
    hour === 0
    ? '12 AM'
    : hour === 12
    ? '12 PM'
    : hour < 12
    ? `${hour} AM`
    : `${hour - 12} PM`;

    const midnight = 0 satisfies HoursEnum;
    const noon = 12 satisfies HoursEnum;
    const elevenPM = 23 satisfies HoursEnum;