Node - time zone box

I have a node (v0.7.3-pre) server with node-cron (0.3.2) and node-time (0.8.2):

var cronJob = require('cron').CronJob; var cronJ = new cronJob({ cronTime: "00 29 16 6 * *", onTick: function() { console.log("Tick"); }, start:true, timeZone: "America/Los_Angeles" }); console.log(cronJ); 

it starts, but Cron always works with server time (UTC), and the returned cron:

 { _callbacks: [ [Function] ], onComplete: undefined, cronTime: { source: '00 29 16 6 * *', zone: undefined, second: { '0': true }, minute: { '29': true }, hour: { '16': true }, dayOfWeek: ... 

zone set as undefined , am i missing something?

+4
source share
1 answer

Due to an error in the node-cron module. I already sent a pull request that will fix it. You can change these lines in a local copy of this module.

You can also use several function parameters to initialize cronJob instead of a single object:

 var cronJob = require('cron').CronJob; var cronJ = new cronJob("00 29 16 6 * *", function() { console.log("Tick"); }, undefined, true, "America/Los_Angeles"); console.log(cronJ); 
+4
source

Source: https://habr.com/ru/post/1416416/


All Articles