timers3000
Version:
Provides a graphical interface in your browser to create and manage incremental timers for your daily tasks.
37 lines (32 loc) • 1.1 kB
JavaScript
function convertSeconds(sec){
var Seconds = sec,Days = Math.floor(Seconds / 86400);
Seconds -= Days * 86400;
var Hours = Math.floor(Seconds / 3600);
Seconds -= Hours * (3600);
var Minutes = Math.floor(Seconds / 60);
Seconds -= Minutes * (60);
var TimeStr = ((Days > 0) ? Days + " days " : "") +
LeadingZero(Hours) + ":" + LeadingZero(Minutes) + ":" + LeadingZero(Seconds)
return TimeStr;
}
function LeadingZero(Time){
return (Time < 10) ? "0" + Time : + Time;
}
function componentToHex(c) {
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
function hexToRgb(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
function formatDate(date){
return moment(parseInt(date)).format('MMMM Do YYYY, h:mm:ss a');
}