From b790be12ef567e5c4a70facead013a266fbda22a Mon Sep 17 00:00:00 2001 From: Bastian Dehn Date: Sun, 9 Jun 2024 13:46:25 +0200 Subject: [PATCH] add formated time with minus --- src/time_format.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.39.5