Skip to content

Commit

Permalink
Fixed negative decimals less than -10 don't work (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuler authored and rauchg committed Dec 3, 2018
1 parent fe0bae3 commit 2669f23
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -50,7 +50,7 @@ function parse(str) {
if (str.length > 100) {
return;
}
var match = /^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
var match = /^((?:\d+)?-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
str
);
if (!match) {
Expand Down
1 change: 1 addition & 0 deletions tests.js
Expand Up @@ -71,6 +71,7 @@ describe('ms(string)', function() {

it('should work with negative decimals', function() {
expect(ms('-1.5h')).to.be(-5400000);
expect(ms('-10.5h')).to.be(-37800000);
});

it('should work with negative decimals starting with "."', function() {
Expand Down

0 comments on commit 2669f23

Please sign in to comment.