cron 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cron.js +2 -1
- package/package.json +1 -1
- package/tests/test-cron.js +38 -0
package/lib/cron.js
CHANGED
|
@@ -96,8 +96,9 @@ CronTime.prototype = {
|
|
|
96
96
|
*/
|
|
97
97
|
sendAt: function() {
|
|
98
98
|
var date = this.realDate ? this.source : moment();
|
|
99
|
+
// Set the timezone if given (http://momentjs.com/timezone/docs/#/using-timezones/parsing-in-zone/)
|
|
99
100
|
if (this.zone)
|
|
100
|
-
date = date.
|
|
101
|
+
date = date.tz(this.zone);
|
|
101
102
|
|
|
102
103
|
if (this.realDate)
|
|
103
104
|
return date;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cron",
|
|
3
3
|
"description": "Cron jobs for your node",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.9",
|
|
5
5
|
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (http://github.com/ncb000gt)",
|
|
6
6
|
"bugs" : {
|
|
7
7
|
"url" : "http://github.com/ncb000gt/node-cron/issues"
|
package/tests/test-cron.js
CHANGED
|
@@ -236,6 +236,44 @@ module.exports = testCase({
|
|
|
236
236
|
clock.restore();
|
|
237
237
|
job.stop();
|
|
238
238
|
},
|
|
239
|
+
'test a job with a string and a given time zone': function (assert) {
|
|
240
|
+
var clock = sinon.useFakeTimers();
|
|
241
|
+
|
|
242
|
+
assert.expect(2);
|
|
243
|
+
|
|
244
|
+
var moment = require("moment-timezone");
|
|
245
|
+
var zone = "America/Chicago";
|
|
246
|
+
|
|
247
|
+
// New Orleans time
|
|
248
|
+
var t = moment();
|
|
249
|
+
t.tz(zone);
|
|
250
|
+
|
|
251
|
+
// Current time
|
|
252
|
+
d = moment();
|
|
253
|
+
|
|
254
|
+
// If current time is New Orleans time, switch to Los Angeles..
|
|
255
|
+
if (t.hours() === d.hours()) {
|
|
256
|
+
zone = "America/Los_Angeles";
|
|
257
|
+
t.tz(zone);
|
|
258
|
+
}
|
|
259
|
+
assert.notEqual(d.hours(), t.hours());
|
|
260
|
+
|
|
261
|
+
// If t = 59s12m then t.setSeconds(60)
|
|
262
|
+
// becones 00s13m so we're fine just doing
|
|
263
|
+
// this and no testRun callback.
|
|
264
|
+
t.add(1, 's');
|
|
265
|
+
// Run a job designed to be executed at a given
|
|
266
|
+
// time in `zone`, making sure that it is a different
|
|
267
|
+
// hour than local time.
|
|
268
|
+
var job = new cron.CronJob(t.seconds() + ' ' + t.minutes() + ' ' + t.hours() + ' * * *', function(){
|
|
269
|
+
assert.ok(true);
|
|
270
|
+
}, null, true, zone);
|
|
271
|
+
|
|
272
|
+
clock.tick(1000);
|
|
273
|
+
clock.restore();
|
|
274
|
+
job.stop();
|
|
275
|
+
assert.done();
|
|
276
|
+
},
|
|
239
277
|
'test a job with a date and a given time zone': function (assert) {
|
|
240
278
|
assert.expect(2);
|
|
241
279
|
|