Skip to content

Commit

Permalink
src: allow RR containing string properties
Browse files Browse the repository at this point in the history
  • Loading branch information
rynobax authored and santigimeno committed May 2, 2017
1 parent aa45a76 commit 6d830f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,8 +407,10 @@ function recurMatch(val, matcher) {
return true;
}

if (typeof matcher === 'number' || typeof matcher === 'string') {
if (typeof matcher === 'number') {
return (val === matcher);
} else if(typeof matcher === 'string') {
return (val === Number(matcher));
} else if (matcher instanceof Range) {
return matcher.contains(val);
} else if (Array.isArray(matcher) || (matcher instanceof Array)) {
Expand Down
11 changes: 11 additions & 0 deletions test/recurrence-rule-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,17 @@ module.exports = {
next = rule.nextInvocationDate(next);
test.equal(next, null);

test.done();
},
"using rule with string properties": function(test) {
var rule = new schedule.RecurrenceRule();
rule.second = '50';
rule.minute = '5';
rule.hour = '10';

var next = rule.nextInvocationDate(base);

test.deepEqual(new Date(2010, 3, 30, 10, 5, 50, 0), next);
test.done();
}
}
Expand Down

0 comments on commit 6d830f0

Please sign in to comment.