From: Bastian Dehn Date: Mon, 10 Jun 2024 14:28:41 +0000 (+0200) Subject: fix tests with local time X-Git-Tag: 1.0.0^2~28 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=ed9fab8407e291106f218768c1fd1fc67cf3354f;p=feierabend.git fix tests with local time --- diff --git a/src/main.c b/src/main.c index b30eafd..c7109ee 100644 --- a/src/main.c +++ b/src/main.c @@ -24,7 +24,7 @@ int main(int argc, char* argv[]) time(&begin); localtime_r(&begin, &begin_tm); - begin_tm.tm_hour = atoi(argv[1]) + begin_tm.tm_gmtoff / ONE_HOUR; + begin_tm.tm_hour = atoi(argv[1]); begin_tm.tm_min = atoi(argv[2]); begin = mktime(&begin_tm); diff --git a/src/time_format.c b/src/time_format.c index 90517ca..4b4806a 100644 --- a/src/time_format.c +++ b/src/time_format.c @@ -7,12 +7,12 @@ void get_time_str(time_t time, char* timestr) if (time < 0) { time *= -1; - gmtime_r(&time, &time_cal); + localtime_r(&time, &time_cal); sprintf(timestr, "-%02d:%02d", time_cal.tm_hour, time_cal.tm_min); return; } - gmtime_r(&time, &time_cal); + localtime_r(&time, &time_cal); sprintf(timestr, "%02d:%02d", time_cal.tm_hour, time_cal.tm_min); } diff --git a/tests/time_format_tests.c b/tests/time_format_tests.c index d0b20d7..4933ada 100644 --- a/tests/time_format_tests.c +++ b/tests/time_format_tests.c @@ -9,7 +9,7 @@ void get_zero_hour_and_fifteen_minutes() { - time_t time = 900; + time_t time = 83700; char* timestring = malloc(sizeof(char) * 7); memset(timestring, 0, 7); @@ -23,7 +23,7 @@ void get_zero_hour_and_fifteen_minutes() void get_five_hour_fourty_five() { - time_t time = 20700; + time_t time = 103500; char* timestring = malloc(sizeof(char) * 7); memset(timestring, 0, 7); @@ -37,7 +37,7 @@ void get_five_hour_fourty_five() void get_minus_five_minutes() { - time_t time = -300; + time_t time = -83100; char* timestring = malloc(sizeof(char) * 7); memset(timestring, 0, 7);