]> gitweb.hhaalo.de Git - feierabend.git/commitdiff
add formated time with minus
authorBastian Dehn <hhaalo@arcor.de>
Sun, 9 Jun 2024 11:46:25 +0000 (13:46 +0200)
committerBastian Dehn <hhaalo@arcor.de>
Sun, 9 Jun 2024 11:46:25 +0000 (13:46 +0200)
src/time_format.c

index 96963b962b4f6c8e3655713352c8e82957ffdbcd..1e2ad72e81e0bad06f224f34ba384e599b0d8aa7 100644 (file)
@@ -4,7 +4,13 @@ void get_time_str(time_t time, char* timestr)
 {
        struct tm time_cal;
 
-       gmtime_r(&time, &time_cal);
+       if (time < 0) {
+               time *= -1;
+               gmtime_r(&time, &time_cal);
+               sprintf(timestr, "-%02d:%02d", time_cal.tm_hour, time_cal.tm_min);
+               return;
+       }
 
+       gmtime_r(&time, &time_cal);
        sprintf(timestr, "%02d:%02d", time_cal.tm_hour, time_cal.tm_min);
 }
\ No newline at end of file