]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
change refactor use worktime end only time_t
authorBastian Dehn <hhaalo@arcor.de>
Mon, 23 Feb 2026 15:20:21 +0000 (16:20 +0100)
committerBastian Dehn <hhaalo@arcor.de>
Mon, 23 Feb 2026 15:21:19 +0000 (16:21 +0100)
src/feierabend.c

index d468f86e218d76b85054afe40bea5d5c2d5080e0..96994d972b63be96b70a751f03c0e87f5621a536 100644 (file)
 #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);