|
@ -4,13 +4,17 @@ $(function () { |
|
|
var HOUR = {name: "hour", nsecs: MINUTE.nsecs * 60}; |
|
|
var HOUR = {name: "hour", nsecs: MINUTE.nsecs * 60}; |
|
|
var DAY = {name: "day", nsecs: HOUR.nsecs * 24}; |
|
|
var DAY = {name: "day", nsecs: HOUR.nsecs * 24}; |
|
|
var WEEK = {name: "week", nsecs: DAY.nsecs * 7}; |
|
|
var WEEK = {name: "week", nsecs: DAY.nsecs * 7}; |
|
|
var MONTH = {name: "month", nsecs: DAY.nsecs * 30}; |
|
|
|
|
|
var UNITS = [MONTH, WEEK, DAY, HOUR, MINUTE]; |
|
|
|
|
|
|
|
|
var UNITS = [WEEK, DAY, HOUR, MINUTE]; |
|
|
|
|
|
|
|
|
var secsToText = function(total) { |
|
|
var secsToText = function(total) { |
|
|
var remainingSeconds = Math.floor(total); |
|
|
var remainingSeconds = Math.floor(total); |
|
|
var result = ""; |
|
|
var result = ""; |
|
|
for (var i=0, unit; unit=UNITS[i]; i++) { |
|
|
for (var i=0, unit; unit=UNITS[i]; i++) { |
|
|
|
|
|
if (unit === WEEK && remainingSeconds % unit.nsecs != 0) { |
|
|
|
|
|
// Say "8 days" instead of "1 week 1 day"
|
|
|
|
|
|
continue |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
var count = Math.floor(remainingSeconds / unit.nsecs); |
|
|
var count = Math.floor(remainingSeconds / unit.nsecs); |
|
|
remainingSeconds = remainingSeconds % unit.nsecs; |
|
|
remainingSeconds = remainingSeconds % unit.nsecs; |
|
|
|
|
|
|
|
|