Skip to content

Commit

Permalink
eliminate the use of the timespan module
Browse files Browse the repository at this point in the history
  • Loading branch information
selaux committed May 7, 2014
1 parent a8a85cf commit cd1a73c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
22 changes: 11 additions & 11 deletions lib/handlebars/helpers/timespan.js
@@ -1,10 +1,9 @@
'use strict';

var _ = require('lodash'),
timespan = require('timespan');
var _ = require('lodash');

module.exports = function (timespanInSeconds) {
var ts,
var remainingSeconds,
tsString = '';

if (typeof timespanInSeconds === 'string') {
Expand All @@ -17,14 +16,15 @@ module.exports = function (timespanInSeconds) {
return '0s';
}

ts = timespan.fromSeconds(timespanInSeconds);
[
'days',
'hours',
'minutes',
'seconds'
].forEach(function (unit) {
var times = ts[unit];
remainingSeconds = timespanInSeconds;
_.each({
days: 60 * 60 * 24,
hours: 60 * 60,
minutes: 60,
seconds: 1
}, function (secondsPerUnit, unit) {
var times = Math.floor(remainingSeconds / secondsPerUnit);
remainingSeconds -= times * secondsPerUnit;

if (tsString !== '' || times !== 0) {
tsString += times + unit.charAt(0).toLowerCase();
Expand Down
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -49,7 +49,6 @@
"serve-favicon": "2.0.0",
"socket.io": "0.9.16",
"stylus": "0.44.0",
"timespan": "2.3.0",
"winston": "0.7.3"
},
"devDependencies": {
Expand Down

0 comments on commit cd1a73c

Please sign in to comment.