Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

time-ago

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

time-ago - npm Package Compare versions

Comparing version
0.0.2
to
0.0.3
+7
test.js
require('./timeago.js')();
console.log(
_timefriendly('1 hour'), _timefriendly('1 hour')===1000*60*60,
_timefriendly('2 days'), _timefriendly('2 days')===1000*60*60*48,
_timefriendly('2 weeks'), _timefriendly('2 weeks')===1000*60*60*24*14
);
+2
-2

@@ -13,3 +13,3 @@ {

},
"main": "timeago.js",
"main": "time-ago.js",
"dependencies": {

@@ -21,3 +21,3 @@ },

},
"version": "0.0.2"
"version": "0.0.3"
}

@@ -20,3 +20,6 @@ timeago

Simple _today() function shows Day, Month, Date, Yr
==> 'Monday, June 1, 1970'
_today() function shows Day, Month, Date, Yr
==> 'Monday, June 1, 1970'
_timefriendly('1 hour') // convert to ms: seconds, minutes, hours, days, weeks, months, years
==> 3600000
module.exports = function(){
var second = 1000,
minute = second*60,
hour = minute*60,
day = hour*24,
week = day*7,
month = day*30,
year = day*365;
global._timeago = function(nd){
var second = 1000, minute = second*60, hour = minute*60, day = hour*24, week = day*7, month = day*30,
year = month*12, r = Math.round, pl = function(v, n){ return n + ' ' + v + (n>1 ? 's':'') + ' ago'};
var r = Math.round, pl = function(v, n){ return n + ' ' + v + (n>1 ? 's':'') + ' ago'};
var ts = new Date().getTime() - new Date(nd).getTime();

@@ -23,2 +30,7 @@ if(ts < second) return ts + ' ms ago';

}
global._timefriendly = function(s){
var t = s.match(/(\d).([a-z]*?)s?$/);
return t[1] * eval(t[2]);
}
}