Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function getDayCountBetweenDates basing on Julian date.
#1
Hi, I wrote short day counter between dates basing on Julian date algorithm.

Function returns the difference of days between dates.

USEFUL FOR PREMIUM ACCOUNTS OR ANOTHER THINGS

Code:
function getDayCountBetweenDates(d1d,d1m,d1y,d2d,d2m,d2y)
{
    local date1 = (1461 * (d1y + 4800 + (d1m - 14)/12))/4 + (367 * (d1m - 2 - 12 * ((d1m - 14)/12)))/12 - (3 * ((d1y + 4900 + (d1m - 14)/12)/100))/4 + d1d - 32075;
    
    
    local date2 = (1461 * (d2y + 4800 + (d2m - 14)/12))/4 + (367 * (d2m - 2 - 12 * ((d2m - 14)/12)))/12 - (3 * ((d2y + 4900 + (d2m - 14)/12)/100))/4 + d2d - 32075;
    
    if(date2 > date1)
    {
        return date2 - date1;
    }
    else
    {
        return date1 - date2;
    }
    
}

Arguments: 

- d1d (int): day of first date
- d1m (int): month of first date
- d1y (int): year of first date

- d2d (int): day of second date
- d2m (int): month of second date
- d2y (int): year of second date
[Image: pjDBIfE.gif]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)