How can i check the days between 2 dates?
#2

pawn Code:
stock CalcDate(&year, &month, &day, extradays)
{
    getdate(year, month, day);
    day += extradays;
    // suppose day = 27 and extradays = 8
    // day is now 35

    switch(month)
    {
        case 1, 3, 5, 7, 8, 10, 12: // 31 day months
        {
            if(day > 31 )
            {
                if(month == 12)
                {
                    month = 1;
                    year++;
                }
                else
                {
                    month++;
                }
                day -= 31; // day is now 4
            }
        }
        case 4, 6, 9, 11: // 30 day months
        {
            if(day > 30 )
            {
                month++;
                day -= 30;
            }
        }
        case 2: // february
        {
            if((day + extradays) > 28 )
            {
                month++;
                day -= 28;
            }
        }
    }
}
Reply


Messages In This Thread
How can i check the days between 2 dates? - by tal_peretz - 03.06.2011, 15:19
Re: How can i check the days between 2 dates? - by Donya - 03.06.2011, 15:35
Re: How can i check the days between 2 dates? - by tal_peretz - 03.06.2011, 15:36
Re: How can i check the days between 2 dates? - by jameskmonger - 03.06.2011, 16:41
Re: How can i check the days between 2 dates? - by tal_peretz - 03.06.2011, 17:26

Forum Jump:


Users browsing this thread: 1 Guest(s)