Skip to content

Commit

Permalink
using node-gmt
Browse files Browse the repository at this point in the history
  • Loading branch information
merencia committed Mar 16, 2018
1 parent 69685f3 commit 62f2da8
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 86 deletions.
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -32,5 +32,8 @@
"istanbul": "^0.4.2",
"mocha": "^3.0.2",
"sinon": "^1.17.3"
},
"dependencies": {
"node-gmt": "^0.0.1"
}
}
4 changes: 2 additions & 2 deletions src/task.js
Expand Up @@ -2,7 +2,7 @@

var convertExpression = require('./convert-expression');
var validatePattern = require('./pattern-validation');
var tz = require('./timezone/timezone-converter');
var GMT = require('node-gmt');

module.exports = (function(){
function matchPattern(pattern, value){
Expand All @@ -15,7 +15,7 @@ module.exports = (function(){

function mustRun(task, date){
if(task.timezone)
date = tz.atTimezone(date, task.timezone);
date = new GMT(task.timezone).relativeDate(date);

var runInSecond = matchPattern(task.expressions[0], date.getSeconds());
var runOnMinute = matchPattern(task.expressions[1], date.getMinutes());
Expand Down
26 changes: 0 additions & 26 deletions src/timezone/timezone-converter.js

This file was deleted.

20 changes: 0 additions & 20 deletions src/timezone/timezones.js

This file was deleted.

7 changes: 3 additions & 4 deletions test/timezone/task-with-timezone-test.js
Expand Up @@ -4,13 +4,12 @@ var expect = require('expect.js');
var sinon = require('sinon');
var Task = require('../../src/task');
var cron = require('../../src/node-cron');
var tz = require('../../src/timezone/timezone-converter')

describe('task at timezone', function () {
it('should should perform at timezone', function () {
var task = new Task('* 4 * * *', function () {
this.executed += 1;
}, "America/Virgin");
}, "GMT-04:00");
task.executed = 0;
var date = new Date('August 19, 2018 00:00:00 GMT-03:00');
date.setHours(date.getHours() + 1);
Expand All @@ -25,7 +24,7 @@ describe('task at timezone', function () {
describe('by node-cron', function () {
beforeEach(function () {
this.now = new Date('August 19, 2018 03:00:00 GMT-04:00');
this.clock = sinon.useFakeTimers(this.now);
this.clock = sinon.useFakeTimers(this.now.getTime());
});

afterEach(function () {
Expand All @@ -39,7 +38,7 @@ describe('task at timezone', function () {
var task = cron.schedule('* 4 * * *', function () {
executed++;
executedAt = new Date();
}, true, "America/Virgin");
}, true, "GMT-04:00");

this.clock.tick(60 * 60 * 1000);
this.now.setHours(this.now.getHours() + 1);
Expand Down
34 changes: 0 additions & 34 deletions test/timezone/timezone-converter-test.js

This file was deleted.

0 comments on commit 62f2da8

Please sign in to comment.