ts-type-forge
    Preparing search index...

    Type Alias MonthIndexEnum

    MonthIndexEnum: Index<12>

    Represents the zero-based index for months of the year. A union of integer literals from 0 (January) to 11 (December).

    This matches JavaScript's Date object month indexing where January = 0. Useful for direct interaction with Date constructors and methods.

    const createDate = (year: number, month: MonthIndexEnum, day: number) => {
    return new Date(year, month, day); // month is 0-based in Date constructor
    };

    const januaryDate = createDate(2024, 0, 1); // January 1, 2024
    const decemberDate = createDate(2024, 11, 31); // December 31, 2024

    // Convert from 1-based to 0-based
    const toMonthIndex = (month: MonthEnum): MonthIndexEnum => (month - 1) as MonthIndexEnum;