21.01.2011, 23:40
I suppose this is realtime?
Something along those lines ..
pawn Код:
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;
}
}
}
}