Cron jobs for Node.js applications that enables developers to execute functions or system commands on schedules defined using standard cron syntax
94
Build a job scheduler that can execute tasks at specific times across different timezones. The scheduler should handle timezone-aware scheduling and support UTC offset configuration for regions without named timezone identifiers.
Create a module that provides the following functionality:
Schedule Jobs with Named Timezones: Create scheduled jobs that execute at specific times in named timezones (e.g., 'America/New_York', 'Europe/London', 'Asia/Tokyo'). The jobs should respect Daylight Saving Time transitions automatically.
Schedule Jobs with UTC Offsets: Support scheduling jobs using UTC offset values in minutes for regions that don't have standard timezone names.
Query Next Execution Time: Provide functionality to query when a scheduled job will execute next, with the result reflecting the configured timezone.
Timezone Validation: Handle invalid timezone names gracefully by throwing appropriate errors when an invalid timezone is provided.
/**
* Creates a job that executes at a specific time in a named timezone
* @param cronExpression - Cron expression for scheduling
* @param timezone - IANA timezone name (e.g., 'America/Los_Angeles')
* @param callback - Function to execute on schedule
* @param autoStart - Whether to start the job immediately
* @returns Job object with control methods
*/
export function createTimezoneJob(
cronExpression: string,
timezone: string,
callback: () => void,
autoStart: boolean
): any;
/**
* Creates a job that executes at a specific time using a UTC offset
* @param cronExpression - Cron expression for scheduling
* @param utcOffsetMinutes - UTC offset in minutes
* @param callback - Function to execute on schedule
* @param autoStart - Whether to start the job immediately
* @returns Job object with control methods
*/
export function createUtcOffsetJob(
cronExpression: string,
utcOffsetMinutes: number,
callback: () => void,
autoStart: boolean
): any;
/**
* Gets the next execution time for a scheduled job in the job's configured timezone
* @param job - The job to query
* @returns The next scheduled execution time
*/
export function getNextExecutionTime(job: any): Date;Provides timezone-aware job scheduling with support for named timezones and UTC offsets, including automatic DST handling.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-cronevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10