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 39 40 41 42 43
| void FinTournee()
{
int ledelta=0;
struct tm tm;
int heures=0, minutes=0, secondes=0;
char L_heure[10];
char la_diff[10];
//On renseigne les champs de fin de tournée
fini=atoi(KMFin);
depart=atoi(KMdepart);
ledelta=fini-depart;
//Calculs de durée
tm.tm_hour=0;
tm.tm_min=0;
tm.tm_sec=0;
strptime(LHeureFin, "%H:%M:%S", &tm);
heures=tm.tm_hour;
minutes=tm.tm_min;
secondes=tm.tm_sec;
strptime(HDeb, "%H:%M:%S", &tm);
tm.tm_hour=heures-tm.tm_hour;
tm.tm_min=minutes-tm.tm_min;
if (tm.tm_min<0)
{
tm.tm_hour=tm.tm_hour-1;
tm.tm_min=60+tm.tm_min;
}
tm.tm_sec=secondes-tm.tm_sec;
if (tm.tm_sec<0)
{
tm.tm_min=tm.tm_min-1;
tm.tm_sec=60+tm.tm_sec;
}
strftime(L_heure,8, "%H:%M:%S", &tm);
printf("L_heure: %s\n",L_heure);
} |