Merge pull request #34179 from RMHonor/master

[node-cron] Define timezone as a string literal
This commit is contained in:
Benjamin Lichtman
2019-04-10 10:29:42 -07:00
committed by GitHub
2 changed files with 12 additions and 2 deletions

View File

@@ -1,9 +1,12 @@
// Type definitions for node-cron 2.0
// Project: https://github.com/node-cron/node-cron, https://github.com/merencia/node-cron
// Definitions by: morsic <https://github.com/maximelkin>,
// burtek <https://github.com/burtek>
// burtek <https://github.com/burtek>,
// Richard Honor <https://github.com/RMHonor>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Timezone } from 'tz-offset';
export function schedule(cronExpression: string, func: () => void, options?: ScheduleOptions): ScheduledTask;
export function validate(cronExpression: string): boolean;
@@ -24,5 +27,5 @@ export interface ScheduleOptions {
/**
* The timezone that is used for job scheduling
*/
timezone?: string;
timezone?: Timezone;
}

View File

@@ -45,3 +45,10 @@ const invalid = cron.validate('60 * * * *');
if (valid && !invalid) {
log('validator works');
}
// check timezones are accepted from the string literal
const tast4 = cron.schedule('* * * * *', () => {
log('will execute every minute until stopped');
}, { timezone: 'Europe/London' });
tast4.destroy();