Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

human-interval

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

human-interval - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

5

History.md
0.1.3 / 2014-01-04
==================
* Added support for months
0.1.2 / 2014-01-03

@@ -3,0 +8,0 @@ ==================

9

index.js

@@ -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);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc