﻿Date.prototype.getDayNumber = function() {
    var onejan = new Date(this.getFullYear(),0,1);
    return Math.ceil((this - onejan) / 86400000) + 1;
}

function getCurrentDateString(CookieName) {
    document.cookie = CookieName + "=" + new Date().toLocaleDateString();
}

function getCurrentDate(CookieName) {
    var currentDate = new Date();

    var year = currentDate.getFullYear();
    var month = currentDate.getMonth() + 1;
    var date = currentDate.getDate();

//    alert(CookieName);
    
    document.cookie = CookieName + "=" + month + "/" + date + "/" + year;
}

function showDateTime(labelObject){
    setInterval("getDateTime('" + labelObject + "')", 10); // Start clock quickly to avoid a flicker!!!
}

function getCurrentDateAuto(CookieName) {
    setInterval("getCurrentDate('" + CookieName + "')", 10); // Start clock quickly to avoid a flicker!!!
}

function getDateTime(divObject) {
    var currentDate = new Date();
    
    var dateString = currentDate.toLocaleDateString() + " " + currentDate.toLocaleTimeString();

    document.getElementById(divObject).innerText = dateString;
}

function SecondsToHHMMSS(inSecs, inAddMinus) {
    sec=parseInt(inSecs);
        
    hours=pad(Math.floor(sec/3600));
    
    minutes=pad(Math.floor((sec%3600)/60));
    
    seconds=pad((sec%3600)%60);

    if (inAddMinus) {
        return "-" + hours + ":" + minutes + ":" + seconds;
    } else {
        return hours + ":" + minutes + ":" + seconds;
    }
    
}

function pad(num){
    num=num+"";
    if(num.length==1){
        num="0" + num;
    }
    return num;   
}

function HHMMSSToSeconds(inHours,inMinutes,inSecs) {
    return (inHours * 3600) + (inMinutes * 60) + inSecs;
}