Skip to content

Commit 2669f23

Browse files
yulerrauchg
authored andcommitted
Fixed negative decimals less than -10 don't work (#111)
1 parent fe0bae3 commit 2669f23

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function parse(str) {
5050
if (str.length > 100) {
5151
return;
5252
}
53-
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(
53+
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(
5454
str
5555
);
5656
if (!match) {

tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ describe('ms(string)', function() {
7171

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

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

0 commit comments

Comments
 (0)