From 1b0b254dd227eb5394a159be42164cd015e4d0cd Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Tue, 11 Jun 2024 19:26:25 +0200 Subject: [PATCH] Revert "fix tests with local time" This reverts commit ed9fab8407e291106f218768c1fd1fc67cf3354f. --- src/main.c | 2 +- src/time_format.c | 4 ++-- tests/time_format_tests.c | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main.c b/src/main.c index af3c4a2..043a080 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,7 @@ int main(int argc, char* argv[]) time(&begin); localtime_r(&begin, &begin_tm); - begin_tm.tm_hour = atoi(argv[1]); + begin_tm.tm_hour = atoi(argv[1]) + begin_tm.tm_gmtoff / ONE_HOUR; begin_tm.tm_min = atoi(argv[2]); begin = mktime(&begin_tm); diff --git a/src/time_format.c b/src/time_format.c index 4b4806a..90517ca 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; - localtime_r(&time, &time_cal); + gmtime_r(&time, &time_cal); sprintf(timestr, "-%02d:%02d", time_cal.tm_hour, time_cal.tm_min); return; } - localtime_r(&time, &time_cal); + gmtime_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 4933ada..d0b20d7 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 = 83700; + time_t time = 900; 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 = 103500; + time_t time = 20700; 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 = -83100; + time_t time = -300; char* timestring = malloc(sizeof(char) * 7); memset(timestring, 0, 7); -- 2.39.5