From 53a8f29c91a13ea0428ddf2bfdedf7a795b5ad31 Mon Sep 17 00:00:00 2001 From: Bohdan Yanchyk Date: Thu, 26 Mar 2020 21:40:49 +0000 Subject: [PATCH] =?UTF-8?q?Aktualizovat=20=E2=80=9Edu3/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du3/program.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/du3/program.c b/du3/program.c index 40e95a5..9338c82 100644 --- a/du3/program.c +++ b/du3/program.c @@ -26,14 +26,23 @@ int main() t.tm_hour = 0; time_t mid = mktime(&t); - // printf("%ld", (long)mid); struct tm* t2 = localtime(&mid); - if(t2->tm_mon + 1 < 10){ - printf(" %d.0%d.%d\n\n", t2->tm_mday, t2->tm_mon + 1, t2->tm_year + 1900); + + 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); + } } else{ - printf(" %d.%d.%d\n\n", t2->tm_mday, t2->tm_mon + 1, t2->tm_year + 1900); + 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); + } } + return 0; /*if (time == (time_t)-1) { printf("fails with error: can't convert date to time!\n");