human-interval
Advanced tools
Comparing version 0.1.2 to 0.1.3
0.1.3 / 2014-01-04 | ||
================== | ||
* Added support for months | ||
0.1.2 / 2014-01-03 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -5,3 +5,3 @@ var humanInterval = module.exports = function humanInterval(time) { | ||
time = swapLanguageToDecimals(time); | ||
time = time.replace(/(second|minute|hour|day|week|year)s?(?! ?(s )?and |s?$)/, '$1,'); | ||
time = time.replace(/(second|minute|hour|day|week|month|year)s?(?! ?(s )?and |s?$)/, '$1,'); | ||
return time.split(/and|,/).reduce(function(sum, group) { | ||
@@ -41,3 +41,3 @@ return sum + processUnits(group); | ||
var num = parseFloat(time, 10), | ||
unit = time.match(/(second|minute|hour|day|week|year)s?/)[1]; | ||
unit = time.match(/(second|minute|hour|day|week|month|year)s?/)[1]; | ||
@@ -49,4 +49,5 @@ switch(unit) { | ||
case 'day': unit = 1000 * 60 * 60 * 24; break; | ||
case 'week': unit = 1000 * 60 * 60 * 24 * 7; break; | ||
case 'year': unit = 1000 * 60 * 60 * 24 * 365; break; | ||
case 'week': unit = 1000 * 60 * 60 * 24 * 7; break; | ||
case 'month': unit = 1000 * 60 * 60 * 24 * 30; break; | ||
case 'year': unit = 1000 * 60 * 60 * 24 * 365; break; | ||
} | ||
@@ -53,0 +54,0 @@ |
{ | ||
"name": "human-interval", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Human readable time measurements", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -40,2 +40,4 @@ # Human Interval | ||
- `days` | ||
- `weeks` | ||
- `months` -- assumes 30 days | ||
- `years` -- assumes 365 days | ||
@@ -42,0 +44,0 @@ |
@@ -29,2 +29,5 @@ var expect = require('expect.js'), | ||
}); | ||
it('understands months', function() { | ||
expect(humanInterval('1 month')).to.be(30 * 86400000); | ||
}); | ||
it('understands years', function() { | ||
@@ -31,0 +34,0 @@ expect(humanInterval('1 year')).to.be(31536000000); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5923
116
57