36 lines
788 B
C
36 lines
788 B
C
// Laboratorio 8 - Esercizio 3 - Datetime.c
|
|
// Matteo Schiff - s295565
|
|
|
|
#include <stdbool.h>
|
|
#include <stdio.h>
|
|
|
|
#include "Datetime.h"
|
|
|
|
int DateTimeCompare(DateTime a, DateTime b) {
|
|
if (a.year > b.year)
|
|
return 1;
|
|
else if (a.year < b.year)
|
|
return -1;
|
|
|
|
if (a.month > b.month)
|
|
return 1;
|
|
else if (a.month < b.month)
|
|
return -1;
|
|
|
|
if (a.day > b.day)
|
|
return 1;
|
|
else if (a.day < b.day)
|
|
return -1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int DateTimeRead(DateTime * dt, FILE * fp) {
|
|
return fscanf(fp, " %d/%d/%d %d:%d", &dt->year, &dt->month,&dt->day,&dt->hours,&dt->minutes) == 5;
|
|
}
|
|
|
|
int DateRead(DateTime * dt, FILE * fp) {
|
|
dt->hours = 0;
|
|
dt->minutes = 0;
|
|
return fscanf(fp, " %d/%d/%d", &dt->year, &dt->month,&dt->day) == 3;
|
|
} |