From b4805d7802ed4c9286b3cbe5c795fdfbb438178a Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Mon, 23 Feb 2026 16:20:21 +0100 Subject: [PATCH] change refactor use worktime end only time_t --- src/feierabend.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/feierabend.c b/src/feierabend.c index d468f86..96994d9 100644 --- a/src/feierabend.c +++ b/src/feierabend.c @@ -21,6 +21,15 @@ #define BREAK_TIME "Pausenzeit" #define WORKTIME_TO "Arbeitszeit bis" +struct tm _get_tm_from_time(const time_t time) +{ + struct tm tm_value; + const struct tm* time_tm = localtime(&time); + memcpy(&tm_value, time_tm, sizeof(struct tm)); + + return tm_value; +} + void _print_german_long_date(const struct tm time_info) { char* weekday = get_weekday_str(time_info.tm_wday); @@ -46,8 +55,9 @@ void _print_long_date_time(const char* label, const struct tm time_tm) void _print_long_work_end_time(const uint8_t soll_hour, const uint8_t soll_minutes, - const struct tm time_tm) + const time_t time) { + const struct tm time_tm = _get_tm_from_time(time); printf("%s %02d:%02d %-9s", WORK_END, soll_hour, @@ -82,15 +92,6 @@ void _print_time_to_end(const uint8_t soll_hour, timestr = NULL; } -struct tm _get_tm_from_time(const time_t time) -{ - struct tm tm_value; - const struct tm* time_tm = localtime(&time); - memcpy(&tm_value, time_tm, sizeof(struct tm)); - - return tm_value; -} - struct tm _init_tm_with_time(const char* hour, const char* min) { struct tm value; @@ -136,9 +137,7 @@ int main(const int argc, const char* argv[]) const struct tm begin_tm = _init_tm_with_time(hour, min); const time_t begin = mktime((struct tm*) &begin_tm); const time_t worktime_eight_end = get_eight_hour_end_worktime(begin); - const struct tm work_eight_end_tm = _get_tm_from_time(worktime_eight_end); const time_t worktime_max_end = get_ten_hour_end_worktime(begin); - const struct tm max_work_end_tm = _get_tm_from_time(worktime_max_end); const time_t brutto_worktime = get_brutto_worktime(begin, now); const time_t netto_worktime = get_current_worktime(begin, now); @@ -150,8 +149,8 @@ int main(const int argc, const char* argv[]) printf("\n"); _print_long_date_time(WORK_BEGIN, begin_tm); - _print_long_work_end_time(SOLL_HOUR, SOLL_MINUTES, work_eight_end_tm); - _print_long_work_end_time(MAX_HOUR, MAX_MINUTES, max_work_end_tm); + _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"); _print_time(BRUTTO_WORKTIME, brutto_worktime); -- 2.47.3