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.1 to 0.1.2

2

component.json
{
"name": "human-interval",
"version": "0.1.1",
"version": "0.1.2",
"repo": "rschmukler/human-interval",

@@ -5,0 +5,0 @@ "description": "Human readable time measurements",

0.1.2 / 2014-01-03
==================
* Added support for 'week' unit
0.1.1 / 2013-10-28

@@ -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|year)s?(?! ?(s )?and |s?$)/, '\$1,');
time = time.replace(/(second|minute|hour|day|week|year)s?(?! ?(s )?and |s?$)/, '$1,');
return time.split(/and|,/).reduce(function(sum, group) {

@@ -26,5 +26,5 @@ return sum + processUnits(group);

function swapLanguageToDecimals(time) {
language = humanInterval.languageMap;
var language = humanInterval.languageMap;
var languageMapRegex = new RegExp('(' + Object.keys(language).join('|') + ')', 'g');
var matches = time.match(languageMapRegex)
var matches = time.match(languageMapRegex);
if(!matches) return time;

@@ -42,3 +42,3 @@

var num = parseFloat(time, 10),
unit = time.match(/(second|minute|hour|day|year)s?/)[1];
unit = time.match(/(second|minute|hour|day|week|year)s?/)[1];

@@ -50,2 +50,3 @@ 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;

@@ -52,0 +53,0 @@ }

{
"name": "human-interval",
"version": "0.1.1",
"version": "0.1.2",
"description": "Human readable time measurements",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -26,2 +26,5 @@ var expect = require('expect.js'),

});
it('understands weeks', function() {
expect(humanInterval('1 week')).to.be(7 * 86400000);
});
it('understands years', function() {

@@ -28,0 +31,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