dateValide

This commit is contained in:
Adrien VAN DAMME 2017-04-05 23:09:18 +02:00
parent f45f74fab6
commit cf1e345e9d
1 changed files with 10 additions and 51 deletions

View File

@ -145,60 +145,19 @@ Bool dateValide(Date * date)
int j = date->jour;
int m = date->moi;
int a = date->annee;
int bis;
if(m != 2)
int daysinmonth[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if(y % 400 == 0 || (y % 100 != 0 && y % 4 == 0))//Si bis février = 29
daysinmonth[1]=29;
if (m<13)
{
if(m >= 1 && m <= 7)
{
if(m %2 == 0)
{
if(j >= 1 && j <= 30) return TRUE;
else return FALSE;
}
else
{
if(j >= 1 && j <= 31) return TRUE;
else return FALSE;
}
}
else if(m > 7 && m <= 12)
{
if(m %2 == 0)
{
if(j >= 1 && j <= 31) return TRUE;
else return FALSE;
}
else
{
if(j >= 1 && j <= 30) return TRUE;
else return FALSE;
}
}
else return FALSE;
if( d <= daysinmonth[m-1] )
return 1;
else
return 0;
}
else
{
if(a %100 == 0)
{
if(a %400 == 0) bis = 1;
else bis = FALSE;
}
else
{
if(a %4 == 0)bis = 1;
else bis = FALSE;
}
if(bis == 1)
{
if(j >= 1 && j <= 29) return TRUE;
else return FALSE;
}
else
{
if(j >= 1 && j <= 28) return TRUE;
else return FALSE;
}
}
return 0;
}
void encoderArticle(Article * article)