Comparing version 0.0.7 to 0.0.8
12
index.js
@@ -35,3 +35,13 @@ var _ = require('underscore'); | ||
var minutes = Math.round(remaining / milli_per_minute); | ||
string = days + " days, " + hours.toString() + ":" + (minutes < 10 ? "0" : "") + minutes.toString() | ||
if (days === 0) { | ||
minutes = Math.floor(remaining / milli_per_minute); | ||
remaining -= minutes*milli_per_minute; | ||
var seconds = Math.round(remaining / 1000); | ||
string = (hours < 10 ? "0" : "")+hours+':'+(minutes < 10 ? "0" : "")+minutes+':'+(seconds < 10 ? "0" : "")+seconds; | ||
} | ||
else { | ||
string = days + " days, " + hours.toString() + ":" + (minutes < 10 ? "0" : "") + minutes.toString(); | ||
} | ||
} else { | ||
@@ -38,0 +48,0 @@ var levels = [ |
{ | ||
"name": "bormat", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "a bunch of boring utility functions for formatting time and numbers, mostly.", | ||
@@ -23,4 +23,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"underscore": ">=1.4.3" | ||
"underscore": ">=1.4.3" | ||
} | ||
} |
@@ -41,2 +41,7 @@ var assert = require('assert'); | ||
it("should be able to output unix uptime format for less than 24 hours", function() { | ||
var timestamp = +new Date() - 3600000 - 120000 - 3000; // 1 hour, 2 minutes, 3 seconds | ||
assert.equal( bormat.timeSince(timestamp, {unixUptime: true}), "01:02:03", "timeSince did not format unix uptime correctly under 24hrs"); | ||
}); | ||
it("should be able to take a time chunk", function() { | ||
@@ -43,0 +48,0 @@ assert.equal( bormat.timeSince({timeChunk: 3600000}), "1 hour"); |
6693
116