2020-03-26 20:05:21 +00:00
|
|
|
#define _XOPEN_SOURCE
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <time.h>
|
|
|
|
|
2020-03-26 22:12:49 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-03-26 20:05:21 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
|
|
|
|
char dateStr[11];
|
|
|
|
struct tm t;
|
2020-03-26 22:12:49 +00:00
|
|
|
int hour = 0, min = 0, secs = 0;
|
2020-03-26 21:38:29 +00:00
|
|
|
|
2020-03-26 20:05:21 +00:00
|
|
|
fgets(dateStr, 11, stdin);
|
2020-03-26 22:12:49 +00:00
|
|
|
sscanf(string , "%d:%d:%d" , &hour,&min,&secs);
|
|
|
|
if(!ValidateTime(hour,min,sec)){
|
|
|
|
printf("Nespravny datum\n");
|
|
|
|
}
|
2020-03-26 21:38:29 +00:00
|
|
|
char* res = strptime(dateStr, "%d.%m.%Y", &t);
|
|
|
|
if (res == NULL) {
|
|
|
|
printf("error: can't parse date!\n");
|
|
|
|
return 1;
|
|
|
|
}
|
2020-03-26 20:05:21 +00:00
|
|
|
|
|
|
|
t.tm_mday += 7;
|
2020-03-26 21:38:29 +00:00
|
|
|
t.tm_sec = 0;
|
|
|
|
t.tm_min = 0;
|
|
|
|
t.tm_hour = 0;
|
|
|
|
|
|
|
|
time_t mid = mktime(&t);
|
|
|
|
struct tm* t2 = localtime(&mid);
|
2020-03-26 20:05:21 +00:00
|
|
|
|
2020-03-26 21:40:49 +00:00
|
|
|
|
|
|
|
if(t2->tm_mday < 10){
|
|
|
|
if(t2->tm_mon + 1 < 10){
|
|
|
|
printf(" %d.0%d.%d\n\n", t2->tm_mday, t2->tm_mon + 1, t2->tm_year + 1900);
|
|
|
|
} else{
|
|
|
|
printf(" %d.%d.%d\n\n", t2->tm_mday, t2->tm_mon + 1, t2->tm_year + 1900);
|
|
|
|
}
|
2020-03-26 21:38:29 +00:00
|
|
|
} else{
|
2020-03-26 21:40:49 +00:00
|
|
|
if(t2->tm_mon + 1 < 10){
|
|
|
|
printf("%d.0%d.%d\n\n", t2->tm_mday, t2->tm_mon + 1, t2->tm_year + 1900);
|
|
|
|
} else{
|
|
|
|
printf("%d.%d.%d\n\n", t2->tm_mday, t2->tm_mon + 1, t2->tm_year + 1900);
|
|
|
|
}
|
2020-03-26 21:38:29 +00:00
|
|
|
}
|
2020-03-26 21:40:49 +00:00
|
|
|
|
2020-03-26 21:38:29 +00:00
|
|
|
return 0;
|
|
|
|
/*if (time == (time_t)-1) {
|
|
|
|
printf("fails with error: can't convert date to time!\n");
|
|
|
|
return 1;
|
|
|
|
}*/
|
|
|
|
|
|
|
|
//t2 = localtime(&sec);
|
|
|
|
|
|
|
|
/*time(&timer);
|
|
|
|
double seconds = difftime(timer,mktime(&t));
|
|
|
|
printf("%.f", seconds);
|
|
|
|
return 0;
|
2020-03-26 20:17:05 +00:00
|
|
|
if(t.tm_mon + 1 < 10){
|
2020-03-26 20:19:33 +00:00
|
|
|
printf(" %d.0%d.%d\n\n", t.tm_mday, t.tm_mon + 1, t.tm_year + 1900);
|
2020-03-26 20:18:00 +00:00
|
|
|
} else{
|
2020-03-26 20:19:33 +00:00
|
|
|
printf(" %d.%d.%d\n\n", t.tm_mday, t.tm_mon + 1, t.tm_year + 1900);
|
2020-03-26 20:17:05 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 20:05:21 +00:00
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
|
2020-03-26 21:38:29 +00:00
|
|
|
return 0;*/
|
2020-03-26 20:05:21 +00:00
|
|
|
}
|