OverviewFilesCommitsIssuesDocsReleasesPeers

apds commits / 51de149

strip down human time
51de149959c12bf264839bf80ffbdd9123d6cd94
by Ev Bogue <ev@evbogue.com> · 2024-12-20T06:09:38.000Z

Changed files (1) +2 -7

lib/human.js +2 -7
……@@ -1,7 +1,6 @@
11export const human = (seconds) => {
22 if (seconds instanceof Date)
33 seconds = Math.round((Date.now() - seconds) / 1000);
4 var suffix = seconds < 0 ? 'from now' : 'ago';
54 seconds = Math.abs(seconds);
65
76 var times = [
……@@ -13,18 +12,14 @@ export const human = (seconds) => {
1312 seconds / 60, // minutes
1413 seconds // seconds
1514 ];
16 var names = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second'];
15 var names = ['y', 'm', 'w', 'd', 'h', 'm', 's'];
1716
1817 for (var i = 0; i < names.length; i++) {
1918 var time = Math.floor(times[i]);
2019 var name = names[i];
21 if (time > 1)
22 name += 's';
23
2420 if (time >= 1)
25 return time + ' ' + name + ' ' + suffix;
21 return time + name;
2622 }
2723 return 'now'
28 //return '0 seconds ' + suffix;
2924}
3025