03.06.2011, 15:19
i fixed it, thanks anyway.
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;
}
}
}
}
stock DatesTime(Start[], End[],&offest)
{
new dtmp[256], idx1, idx2;
dtmp = strtok(Start, idx1, '.');
new StartDay = strval(dtmp);
dtmp = strtok(Start, idx1, '.');
new StartMonth = strval(dtmp);
dtmp = strtok(Start, idx1, '.');
new StartYear = strval(dtmp);
dtmp = strtok(End, idx2, '.');
new EndDay = strval(dtmp);
dtmp = strtok(End, idx2, '.');
new EndMonth = strval(dtmp);
dtmp = strtok(End, idx2, '.');
new EndYear = strval(dtmp);
new init_date = mktime(12,0,0,StartDay,StartMonth,StartYear);
new dest_date = mktime(12,0,0,EndDay,EndMonth,EndYear);
offest = dest_date - init_date;
offest = floatround(offest/60/60/24, floatround_floor);
return 1;
}