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");