pvjc20/du3/program.c

36 lines
607 B
C
Raw Normal View History

2020-03-27 02:39:01 +00:00
#define __USE_XOPEN
#define _GNU_SOURCE
#include<stdio.h>
#include<time.h>
#include<stdlib.h>
int main() {
char buffer[20];
2020-03-27 02:57:44 +00:00
struct tm tm = {0};
2020-03-27 02:39:01 +00:00
char *retval = fgets(buffer, sizeof(buffer), stdin);
if (retval == 0) {
puts("Neplatny datum");
return 0;
}
retval = strptime(buffer, "%e.%m.%-Y", &tm);
if (retval == 0) {
puts("Neplatny datum");
return 0;
}
2020-03-27 02:57:44 +00:00
tm.tm_isdst = -1;
2020-03-27 02:39:01 +00:00
tm.tm_mday += 7;
2020-03-27 02:57:44 +00:00
mktime(&tm);
2020-03-27 02:39:01 +00:00
strftime(buffer, sizeof(buffer), "%e.%m.%-Y", &tm);
puts(buffer);
2020-03-27 02:41:40 +00:00
putc('\n', stdout);
2020-03-27 02:39:01 +00:00
return 0;
}