Skip to content

Commit

Permalink
Fix pluralization when return is zero. Closes #187
Browse files Browse the repository at this point in the history
  • Loading branch information
Edson Hilios committed Aug 3, 2016
1 parent 0d9e5d2 commit 0973e35
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,11 @@
plural = format[1];
}
}
if(Math.abs(count) === 1) {
return singular;
} else {
// Fix #187
if(Math.abs(count) > 1) {
return plural;
} else {
return singular;
}
}
// The Final Countdown
Expand Down
9 changes: 9 additions & 0 deletions test/unit/strftime_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ test('return the singular when given pair of arguments', function() {
$clock.tick(500);
});

test('return the singular for zero (issue #187)', function() {
$dom.countdown(new Date().valueOf() + 1000)
.on('update.countdown', function(event) {
ok(event.offset.seconds === 1);
ok(event.strftime('%m %!m:min,minutes;') === '00 min');
});
$clock.tick(500);
});

test('return the correct plural even with odd looking (issue #70)', function() {
$dom.countdown(new Date().valueOf() + 2 * 60 * 1000)
.on('update.countdown', function(event) {
Expand Down

0 comments on commit 0973e35

Please sign in to comment.