diff --git a/VANDAMME27.c b/VANDAMME27.c index 12052b1..cf49616 100644 --- a/VANDAMME27.c +++ b/VANDAMME27.c @@ -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)