function getDayOffsetToGenerate()

in src/main.ts [71:98]


function getDayOffsetToGenerate(): number | null {
    // This function is not pure, its return value depends on the time of the day.
    // It returns ether a number or null.
    // null signifies that a file should not be generated at this time.
    // Otherwise the number id a day index of the file.

    const dayIndexesForHour:Record<number, number> = {
        5: 2, // used if all working days
        6: 3, // used on thursday for sunday
        7: 4, // used on thursday for monday
        8: 5, // used on thursday for tuesday (if monday is a bank holiday)
        9: 6, // used on wednesday for tuesday (if its easter weekend)
        10: 7, // preview
        11: 8, // preview
        12: 9, // preview
        13: 10, // preview
        14: 11, // preview
        15: 12, // preview
        16: 13, // preview
        17: 14, // preview
    };

    let currentHour: number = new Date().getUTCHours();

    const dayIndex: number | null = dayIndexesForHour[currentHour] || null;

    return dayIndex;
}