1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
int Conversion_date(string date) /* date au format jj/mm/aaaa */
{
int jour = 0; int mois = 0; int annee = 0; int jour_semaine = 10;
struct tm time;
stringstream flux(date);
int nb_cell = 0;
string cell;
while (getline(flux, cell, '/')){
switch (nb_cell){
case 0:
jour = atoi(cell.c_str());
break;
case 1:
mois = atoi(cell.c_str());
break;
case 2:
annee = atoi(cell.c_str());
break;
}
++nb_cell;
}
time.tm_mday = jour;
time.tm_mon = mois - 1;
time.tm_year = (annee - 1900);
time.tm_hour = 0; time.tm_min = 0; time.tm_sec = 0;
if (mktime(&time)==-1){
printf("Erreur, le format de la date n'est pas correct\n");
system("PAUSE");exit(EXIT_FAILURE);
}
jour_semaine = time.tm_wday;
return (jour_semaine);
} |
Partager