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 j = date->jour;
int m = date->moi; int m = date->moi;
int a = date->annee; int a = date->annee;
int bis; int daysinmonth[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if(m != 2)
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( d <= daysinmonth[m-1] )
{ return 1;
if(m %2 == 0) else
{ return 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;
} }
else else
{ return 0;
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;
}
}
} }
void encoderArticle(Article * article) void encoderArticle(Article * article)