﻿/* FILE RESPONSIBLE FOR MANIPULATING DATES 
   AUTHOR: BRUNO CASARI
*/

var MILLISECONDS_IN_DAY = 86400000;   
var MILLISECONDS_IN_HOUR = 3600000;
var MILLISECONDS_IN_MINUTE = 60000;    
var MILLISECONDS_IN_SECOND = 1000;

/*Method used to return the difference in millis between two dates */
function GetMillisDifferentBetweenDates(firstDate, secondDate) {
    var difference = secondDate - firstDate;

    if (difference < 0) difference = 0;

    return difference;
}

//Returns the number of days in a specific number of milliseconds
function DaysIn(milliseconds)
{
    return Math.floor(milliseconds / MILLISECONDS_IN_DAY); 
}

//Returns the number of hours in a specific number of milliseconds
function HoursIn(milliseconds)
{
    return Math.floor(milliseconds / MILLISECONDS_IN_HOUR) % 24;
}

//Returns the number of minutes in a specific number of milliseconds
function MinutesIn(milliseconds)
{
    return Math.floor(milliseconds / MILLISECONDS_IN_MINUTE) % 60;
}

//Returns the number of seconds in a specific number of milliseconds
function SecondsIn(milliseconds)
{
    return Math.floor(milliseconds / MILLISECONDS_IN_SECOND) % 60;
}


