How could I be calculating the days between 2 dates?
#3

Here is the magic code: (it take cares of leap years as well)

pawn Код:
rdn(year, month, day) // Rata Die day
{
    if (month < 3)
    {
        year--;
        month += 12;
    }
    return ((365*year) + (year/4) - (year/100) + (year/400) + (((153*month) - 457)/5) + (day - 306));
}
How to use:
pawn Код:
new num_days = (rdn(2017, 1, 1) - rdn(2016, 1, 1));
Reply


Messages In This Thread
How could I be calculating the days between 2 dates? - by danielpalade - 30.07.2016, 01:57
Re: How could I be calculating the days between 2 dates? - by Luicy. - 30.07.2016, 02:11
Re: How could I be calculating the days between 2 dates? - by Gammix - 30.07.2016, 02:49

Forum Jump:


Users browsing this thread: 1 Guest(s)