diff --git a/du3/program.c b/du3/program.c index 9338c82..3ab7607 100644 --- a/du3/program.c +++ b/du3/program.c @@ -4,16 +4,29 @@ #include #include +int ValidateTime(int hh , int mm , int ss) +{ + int ret=0; + + if(hh>24) ret=1; + if(mm>60) ret=1; + if(ss>60) ret=1; + + return ret; +} + int main() { char dateStr[11]; struct tm t; - - + int hour = 0, min = 0, secs = 0; fgets(dateStr, 11, stdin); - + sscanf(string , "%d:%d:%d" , &hour,&min,&secs); + if(!ValidateTime(hour,min,sec)){ + printf("Nespravny datum\n"); + } char* res = strptime(dateStr, "%d.%m.%Y", &t); if (res == NULL) { printf("error: can't parse date!\n");