in serializer/src/agenttypesystem.c [793:905]
static int ValidateDate(int year, int month, int day)
{
int result;
if ((year <= -10000) || (year >= 10000))
{
result = 1;
}
else
{
if (day <= 0)
{
result = 1;
}
else
{
/*the following data will be validated...*/
/*leap years are those that can be divided by 4. But if the year can be divided by 100, it is not leap. But if they year can be divided by 400 it is leap*/
if (
(month == 1) || /*these months have always 31 days*/
(month == 3) ||
(month == 5) ||
(month == 7) ||
(month == 8) ||
(month == 10) ||
(month == 12)
)
{
if (day <= 31)
{
result = 0;
}
else
{
result = 1;
}
}
else if (
(month == 4) ||
(month == 6) ||
(month == 9) ||
(month == 11)
)
{
if (day <= 30)
{
result = 0;
}
else
{
result = -1;
}
}
else if (month == 2)/*february*/
{
if ((year % 400) == 0)
{
/*these are leap years, suchs as 2000*/
if (day <= 29)
{
result = 0;
}
else
{
result = 1;
}
}
else if ((year % 100) == 0)
{
/*non-leap year, such as 1900*/
if (day <= 28)
{
result = 0;
}
else
{
result = 1;
}
}
else if ((year % 4) == 0)
{
/*these are leap years, such as 2104*/
if (day <= 29)
{
result = 0;
}
else
{
result = 1;
}
}
else
{
/*certainly not a leap year*/
if (day <= 28)
{
result = 0;
}
else
{
result = 1;
}
}
}
else
{
result = 1;
}
}
}
return result;
}