From: Bastian Dehn Date: Sun, 9 Jun 2024 11:46:25 +0000 (+0200) Subject: add formated time with minus X-Git-Tag: 1.0.0^2~39 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=b790be12ef567e5c4a70facead013a266fbda22a;p=feierabend.git add formated time with minus --- diff --git a/src/time_format.c b/src/time_format.c index 96963b9..1e2ad72 100644 --- a/src/time_format.c +++ b/src/time_format.c @@ -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