Edits history of script submission #14000 for ' Dynamic skip template (windmill)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    // Dynamic skip template
    // Return true to execute the scheduled job, false to skip to next occurrence
    
    export async function main(
      scheduled_for: string // The proposed datetime for the scheduled job (ISO 8601 format)
    ): Promise<boolean> {
      // Example: Skip weekends
      // const date = new Date(scheduled_for);
      // const dayOfWeek = date.getDay(); // 0 = Sunday, 6 = Saturday
      // if (dayOfWeek === 0 || dayOfWeek === 6) {
      //   console.log(`Skipping weekend execution at ${scheduled_for}`);
      //   return false;
      // }
    
      // Example: Skip holidays
      // const holidays = ['2024-12-25', '2024-01-01'];
      // const date = new Date(scheduled_for);
      // const dateStr = date.toISOString().split('T')[0];
      // if (holidays.includes(dateStr)) {
      //   console.log(`Skipping holiday execution at ${scheduled_for}`);
      //   return false;
      // }
    
      console.log(`Allowing execution at ${scheduled_for}`);
      return true;
    }
    

    Submitted by hugo697 223 days ago