{"action":"created","comment":{"url":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/comments/42026311","id":42026311,"diff_hunk":"@@ -255,6 +255,60 @@ module.exports = {\n       test.deepEqual(new Date(2011, 5, 1, 0, 0, 0, 0), next);\n \n       test.done();\n+    },\n+    \"specify 5 second variation (test that variation is within specified range)\": function(test) {\n+      test.expect(8);\n+\n+      var rule = new schedule.RecurrenceRule();\n+      rule.second = [0,15,30,45];\n+      rule.variation = 5;\n+\n+      var scheduledDates = [\n+        new Date(2010, 3, 29, 12, 30, 30, 0),\n+        new Date(2010, 3, 29, 12, 30, 45, 0),\n+        new Date(2010, 3, 29, 12, 31, 00, 0),\n+        new Date(2010, 3, 29, 12, 31, 15, 0)\n+      ]\n+\n+      var next = base;\n+      scheduledDates.forEach(function(date){\n+        var inv = new schedule.Invocation(null, rule.nextInvocationDate(next), rule);\n+        next = inv.scheduleDate;\n+\n+        test.deepEqual(date, inv.scheduleDate);\n+        test.ok(Math.abs(inv.fireDate - inv.scheduleDate) <= 5000);\n+      });\n+\n+      test.done();\n+    },\n+    \"specify 5 second variation (override variation to test exact fireDate)\": function(test) {\n+      test.expect(8);\n+\n+      var rule = new schedule.RecurrenceRule();\n+      rule.second = [0,15,30,45];\n+      rule.variation = 5;\n+\n+      schedule.Invocation.prototype.random = function(){","path":"test/recurrence-rule-test.js","position":37,"original_position":37,"commit_id":"83df4aaaf5faf132751767ed602051d8ce41e688","original_commit_id":"83df4aaaf5faf132751767ed602051d8ce41e688","user":{"login":"santigimeno","id":1084056,"avatar_url":"https://avatars.githubusercontent.com/u/1084056?v=3","gravatar_id":"","url":"https://api.github.com/users/santigimeno","html_url":"https://github.com/santigimeno","followers_url":"https://api.github.com/users/santigimeno/followers","following_url":"https://api.github.com/users/santigimeno/following{/other_user}","gists_url":"https://api.github.com/users/santigimeno/gists{/gist_id}","starred_url":"https://api.github.com/users/santigimeno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/santigimeno/subscriptions","organizations_url":"https://api.github.com/users/santigimeno/orgs","repos_url":"https://api.github.com/users/santigimeno/repos","events_url":"https://api.github.com/users/santigimeno/events{/privacy}","received_events_url":"https://api.github.com/users/santigimeno/received_events","type":"User","site_admin":false},"body":"Oh, I see the reason of `Invocation.prototype.random` now. Couldn't we just mock Math.random?","created_at":"2015-10-14T17:41:19Z","updated_at":"2015-10-14T17:41:19Z","html_url":"https://github.com/tejasmanohar/node-schedule/pull/190#discussion_r42026311","pull_request_url":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/190","_links":{"self":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/comments/42026311"},"html":{"href":"https://github.com/tejasmanohar/node-schedule/pull/190#discussion_r42026311"},"pull_request":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/190"}}},"pull_request":{"url":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/190","id":47416083,"html_url":"https://github.com/tejasmanohar/node-schedule/pull/190","diff_url":"https://github.com/tejasmanohar/node-schedule/pull/190.diff","patch_url":"https://github.com/tejasmanohar/node-schedule/pull/190.patch","issue_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/190","number":190,"state":"open","locked":false,"title":"Allow for varying an invocations fireDate by a specified number of seconds","user":{"login":"andy-g","id":557065,"avatar_url":"https://avatars.githubusercontent.com/u/557065?v=3","gravatar_id":"","url":"https://api.github.com/users/andy-g","html_url":"https://github.com/andy-g","followers_url":"https://api.github.com/users/andy-g/followers","following_url":"https://api.github.com/users/andy-g/following{/other_user}","gists_url":"https://api.github.com/users/andy-g/gists{/gist_id}","starred_url":"https://api.github.com/users/andy-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy-g/subscriptions","organizations_url":"https://api.github.com/users/andy-g/orgs","repos_url":"https://api.github.com/users/andy-g/repos","events_url":"https://api.github.com/users/andy-g/events{/privacy}","received_events_url":"https://api.github.com/users/andy-g/received_events","type":"User","site_admin":false},"body":"I required functionality to randomly vary my invocations by a specified range, for example, specifying a schedule for every hour, but allowing a variation of 5 minutes, in which case the 12:00 Invocation may run at anytime between 11:55 - 12:05.\r\n\r\nAlthough this is relatively specific functionality I assume that it may be useful to others, so decided to create this Pull Request.\r\n\r\nAll existing functionality remains unchanged, but a new `variation` property is available on the rule object, which if specified will adjust the resulting invocations accordingly.\r\n\r\n```javascript\r\nvar rule = new schedule.RecurrenceRule();\r\nrule.minute = 0;\r\nrule.variation = 300;\r\n\r\nvar j = schedule.scheduleJob(rule, function(){\r\n    console.log('within 5 minutes before or after the hour');\r\n});\r\n```\r\n\r\nI've also added some associated tests.","created_at":"2015-10-12T12:52:46Z","updated_at":"2015-10-14T17:41:19Z","closed_at":null,"merged_at":null,"merge_commit_sha":"68d1ae1489b9eee6026df9d22e743151f9096600","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/190/commits","review_comments_url":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/190/comments","review_comment_url":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/190/comments","statuses_url":"https://api.github.com/repos/tejasmanohar/node-schedule/statuses/83df4aaaf5faf132751767ed602051d8ce41e688","head":{"label":"andy-g:feature/variation","ref":"feature/variation","sha":"83df4aaaf5faf132751767ed602051d8ce41e688","user":{"login":"andy-g","id":557065,"avatar_url":"https://avatars.githubusercontent.com/u/557065?v=3","gravatar_id":"","url":"https://api.github.com/users/andy-g","html_url":"https://github.com/andy-g","followers_url":"https://api.github.com/users/andy-g/followers","following_url":"https://api.github.com/users/andy-g/following{/other_user}","gists_url":"https://api.github.com/users/andy-g/gists{/gist_id}","starred_url":"https://api.github.com/users/andy-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy-g/subscriptions","organizations_url":"https://api.github.com/users/andy-g/orgs","repos_url":"https://api.github.com/users/andy-g/repos","events_url":"https://api.github.com/users/andy-g/events{/privacy}","received_events_url":"https://api.github.com/users/andy-g/received_events","type":"User","site_admin":false},"repo":{"id":12646278,"name":"node-schedule","full_name":"andy-g/node-schedule","owner":{"login":"andy-g","id":557065,"avatar_url":"https://avatars.githubusercontent.com/u/557065?v=3","gravatar_id":"","url":"https://api.github.com/users/andy-g","html_url":"https://github.com/andy-g","followers_url":"https://api.github.com/users/andy-g/followers","following_url":"https://api.github.com/users/andy-g/following{/other_user}","gists_url":"https://api.github.com/users/andy-g/gists{/gist_id}","starred_url":"https://api.github.com/users/andy-g/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy-g/subscriptions","organizations_url":"https://api.github.com/users/andy-g/orgs","repos_url":"https://api.github.com/users/andy-g/repos","events_url":"https://api.github.com/users/andy-g/events{/privacy}","received_events_url":"https://api.github.com/users/andy-g/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/andy-g/node-schedule","description":"A cron-like and not-cron-like job scheduler for Node.","fork":true,"url":"https://api.github.com/repos/andy-g/node-schedule","forks_url":"https://api.github.com/repos/andy-g/node-schedule/forks","keys_url":"https://api.github.com/repos/andy-g/node-schedule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/andy-g/node-schedule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/andy-g/node-schedule/teams","hooks_url":"https://api.github.com/repos/andy-g/node-schedule/hooks","issue_events_url":"https://api.github.com/repos/andy-g/node-schedule/issues/events{/number}","events_url":"https://api.github.com/repos/andy-g/node-schedule/events","assignees_url":"https://api.github.com/repos/andy-g/node-schedule/assignees{/user}","branches_url":"https://api.github.com/repos/andy-g/node-schedule/branches{/branch}","tags_url":"https://api.github.com/repos/andy-g/node-schedule/tags","blobs_url":"https://api.github.com/repos/andy-g/node-schedule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/andy-g/node-schedule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/andy-g/node-schedule/git/refs{/sha}","trees_url":"https://api.github.com/repos/andy-g/node-schedule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/andy-g/node-schedule/statuses/{sha}","languages_url":"https://api.github.com/repos/andy-g/node-schedule/languages","stargazers_url":"https://api.github.com/repos/andy-g/node-schedule/stargazers","contributors_url":"https://api.github.com/repos/andy-g/node-schedule/contributors","subscribers_url":"https://api.github.com/repos/andy-g/node-schedule/subscribers","subscription_url":"https://api.github.com/repos/andy-g/node-schedule/subscription","commits_url":"https://api.github.com/repos/andy-g/node-schedule/commits{/sha}","git_commits_url":"https://api.github.com/repos/andy-g/node-schedule/git/commits{/sha}","comments_url":"https://api.github.com/repos/andy-g/node-schedule/comments{/number}","issue_comment_url":"https://api.github.com/repos/andy-g/node-schedule/issues/comments{/number}","contents_url":"https://api.github.com/repos/andy-g/node-schedule/contents/{+path}","compare_url":"https://api.github.com/repos/andy-g/node-schedule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/andy-g/node-schedule/merges","archive_url":"https://api.github.com/repos/andy-g/node-schedule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/andy-g/node-schedule/downloads","issues_url":"https://api.github.com/repos/andy-g/node-schedule/issues{/number}","pulls_url":"https://api.github.com/repos/andy-g/node-schedule/pulls{/number}","milestones_url":"https://api.github.com/repos/andy-g/node-schedule/milestones{/number}","notifications_url":"https://api.github.com/repos/andy-g/node-schedule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/andy-g/node-schedule/labels{/name}","releases_url":"https://api.github.com/repos/andy-g/node-schedule/releases{/id}","created_at":"2013-09-06T14:35:35Z","updated_at":"2015-03-01T18:44:45Z","pushed_at":"2015-10-12T12:57:05Z","git_url":"git://github.com/andy-g/node-schedule.git","ssh_url":"git@github.com:andy-g/node-schedule.git","clone_url":"https://github.com/andy-g/node-schedule.git","svn_url":"https://github.com/andy-g/node-schedule","homepage":"","size":250,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"tejasmanohar:master","ref":"master","sha":"1e7e09bfd8cf3a1538be803e10f29e795603602c","user":{"login":"tejasmanohar","id":5959235,"avatar_url":"https://avatars.githubusercontent.com/u/5959235?v=3","gravatar_id":"","url":"https://api.github.com/users/tejasmanohar","html_url":"https://github.com/tejasmanohar","followers_url":"https://api.github.com/users/tejasmanohar/followers","following_url":"https://api.github.com/users/tejasmanohar/following{/other_user}","gists_url":"https://api.github.com/users/tejasmanohar/gists{/gist_id}","starred_url":"https://api.github.com/users/tejasmanohar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tejasmanohar/subscriptions","organizations_url":"https://api.github.com/users/tejasmanohar/orgs","repos_url":"https://api.github.com/users/tejasmanohar/repos","events_url":"https://api.github.com/users/tejasmanohar/events{/privacy}","received_events_url":"https://api.github.com/users/tejasmanohar/received_events","type":"User","site_admin":false},"repo":{"id":1735515,"name":"node-schedule","full_name":"tejasmanohar/node-schedule","owner":{"login":"tejasmanohar","id":5959235,"avatar_url":"https://avatars.githubusercontent.com/u/5959235?v=3","gravatar_id":"","url":"https://api.github.com/users/tejasmanohar","html_url":"https://github.com/tejasmanohar","followers_url":"https://api.github.com/users/tejasmanohar/followers","following_url":"https://api.github.com/users/tejasmanohar/following{/other_user}","gists_url":"https://api.github.com/users/tejasmanohar/gists{/gist_id}","starred_url":"https://api.github.com/users/tejasmanohar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tejasmanohar/subscriptions","organizations_url":"https://api.github.com/users/tejasmanohar/orgs","repos_url":"https://api.github.com/users/tejasmanohar/repos","events_url":"https://api.github.com/users/tejasmanohar/events{/privacy}","received_events_url":"https://api.github.com/users/tejasmanohar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tejasmanohar/node-schedule","description":"A cron-like and not-cron-like job scheduler for Node.","fork":false,"url":"https://api.github.com/repos/tejasmanohar/node-schedule","forks_url":"https://api.github.com/repos/tejasmanohar/node-schedule/forks","keys_url":"https://api.github.com/repos/tejasmanohar/node-schedule/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tejasmanohar/node-schedule/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tejasmanohar/node-schedule/teams","hooks_url":"https://api.github.com/repos/tejasmanohar/node-schedule/hooks","issue_events_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/events{/number}","events_url":"https://api.github.com/repos/tejasmanohar/node-schedule/events","assignees_url":"https://api.github.com/repos/tejasmanohar/node-schedule/assignees{/user}","branches_url":"https://api.github.com/repos/tejasmanohar/node-schedule/branches{/branch}","tags_url":"https://api.github.com/repos/tejasmanohar/node-schedule/tags","blobs_url":"https://api.github.com/repos/tejasmanohar/node-schedule/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tejasmanohar/node-schedule/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tejasmanohar/node-schedule/git/refs{/sha}","trees_url":"https://api.github.com/repos/tejasmanohar/node-schedule/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tejasmanohar/node-schedule/statuses/{sha}","languages_url":"https://api.github.com/repos/tejasmanohar/node-schedule/languages","stargazers_url":"https://api.github.com/repos/tejasmanohar/node-schedule/stargazers","contributors_url":"https://api.github.com/repos/tejasmanohar/node-schedule/contributors","subscribers_url":"https://api.github.com/repos/tejasmanohar/node-schedule/subscribers","subscription_url":"https://api.github.com/repos/tejasmanohar/node-schedule/subscription","commits_url":"https://api.github.com/repos/tejasmanohar/node-schedule/commits{/sha}","git_commits_url":"https://api.github.com/repos/tejasmanohar/node-schedule/git/commits{/sha}","comments_url":"https://api.github.com/repos/tejasmanohar/node-schedule/comments{/number}","issue_comment_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/comments{/number}","contents_url":"https://api.github.com/repos/tejasmanohar/node-schedule/contents/{+path}","compare_url":"https://api.github.com/repos/tejasmanohar/node-schedule/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tejasmanohar/node-schedule/merges","archive_url":"https://api.github.com/repos/tejasmanohar/node-schedule/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tejasmanohar/node-schedule/downloads","issues_url":"https://api.github.com/repos/tejasmanohar/node-schedule/issues{/number}","pulls_url":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls{/number}","milestones_url":"https://api.github.com/repos/tejasmanohar/node-schedule/milestones{/number}","notifications_url":"https://api.github.com/repos/tejasmanohar/node-schedule/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tejasmanohar/node-schedule/labels{/name}","releases_url":"https://api.github.com/repos/tejasmanohar/node-schedule/releases{/id}","created_at":"2011-05-11T21:41:34Z","updated_at":"2015-10-14T11:54:12Z","pushed_at":"2015-10-12T12:57:06Z","git_url":"git://github.com/tejasmanohar/node-schedule.git","ssh_url":"git@github.com:tejasmanohar/node-schedule.git","clone_url":"https://github.com/tejasmanohar/node-schedule.git","svn_url":"https://github.com/tejasmanohar/node-schedule","homepage":"","size":983,"stargazers_count":1588,"watchers_count":1588,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":113,"mirror_url":null,"open_issues_count":16,"forks":113,"open_issues":16,"watchers":1588,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/190"},"html":{"href":"https://github.com/tejasmanohar/node-schedule/pull/190"},"issue":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/190"},"comments":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/issues/190/comments"},"review_comments":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/190/comments"},"review_comment":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/pulls/190/commits"},"statuses":{"href":"https://api.github.com/repos/tejasmanohar/node-schedule/statuses/83df4aaaf5faf132751767ed602051d8ce41e688"}}}}