02.01.2013, 19:44
PHP код:
stock GetAge(string[])
{
new var0, var1, var2, Date[3], age;
sscanf(string, "p<.>iii", var0, var1, var2);
if(var0 > 31 || var0 <= 0)return 0;
if(var1 > 12 || var1 <= 0)return 0;
getdate(Date[0],Date[1],Date[2]);
if(var2 > Date[0] || var2 < 1900)return 0;
age = Date[0] - var2 - ((Date[1] < var1)? 1 : ((Date[1] == var1 && Date[2] < var0)? 1 : 0));
return age;
}