weekday = NULL;
}
-void _print_long_date_time(const char* label, const struct tm time_tm)
+void _print_long_date_time(const char* label, const time_t time)
{
+ const struct tm time_tm = _get_tm_from_time(time);
printf("%-27s", label);
_print_german_long_date(time_tm);
printf("\n");
timestr = NULL;
}
-struct tm _init_tm_with_time(const char* hour, const char* min)
+time_t _init_tm_with_time(const char* hour, const char* min)
{
- struct tm value;
const time_t now = time(NULL);
- const struct tm* now_tm = localtime(&now);
- memcpy(&value, now_tm, sizeof(struct tm));
-
- if (hour != NULL)
- value.tm_hour = atoi(hour);
+ struct tm now_tm = _get_tm_from_time(now);
+ now_tm.tm_hour = atoi(hour);
+ now_tm.tm_min = atoi(min);
- if (min != NULL)
- value.tm_min = atoi(min);
-
- return value;
+ return mktime(&now_tm);
}
int _few_arguments(const char* argv[])
printf("Version: %s\n\n", PROJECT_VERSION);
- const struct tm now_tm = _init_tm_with_time(NULL, NULL);
- const time_t now = mktime((struct tm*) &now_tm);
- const struct tm begin_tm = _init_tm_with_time(hour, min);
- const time_t begin = mktime((struct tm*) &begin_tm);
+ const time_t now = time(NULL);
+ const time_t begin = _init_tm_with_time(hour, min);
const time_t worktime_eight_end = get_eight_hour_end_worktime(begin);
const time_t worktime_max_end = get_ten_hour_end_worktime(begin);
const time_t diff_to_end = get_current_worktime_diff_to_end_eight_hour(begin, now);
const time_t diff_to_max_end = get_current_worktime_diff_to_end_ten_hour(begin, now);
- _print_long_date_time(CURRENT_TIME, now_tm);
+ _print_long_date_time(CURRENT_TIME, now);
printf("\n");
- _print_long_date_time(WORK_BEGIN, begin_tm);
+ _print_long_date_time(WORK_BEGIN, begin);
_print_long_work_end_time(SOLL_HOUR, SOLL_MINUTES, worktime_eight_end);
_print_long_work_end_time(MAX_HOUR, MAX_MINUTES, worktime_max_end);
printf("\n");