summaryrefslogtreecommitdiffstats
path: root/sysdep/unix
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2000-06-01 17:13:23 +0200
committerMartin Mares <mj@ucw.cz>2000-06-01 17:13:23 +0200
commitb594ad238692738352cd8827d71038a356b0d5a5 (patch)
tree849827534ed3b3a1ce99fd9cf349b0eaaf17626b /sysdep/unix
parentc23f40b1458e448ec9e7c974a2c486f2eccff871 (diff)
downloadbird-b594ad238692738352cd8827d71038a356b0d5a5.tar
bird-b594ad238692738352cd8827d71038a356b0d5a5.zip
tm_format_reltime() works with both past and future timestamps.
Diffstat (limited to 'sysdep/unix')
-rw-r--r--sysdep/unix/io.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/sysdep/unix/io.c b/sysdep/unix/io.c
index 471944c..9d80b7d 100644
--- a/sysdep/unix/io.c
+++ b/sysdep/unix/io.c
@@ -305,13 +305,11 @@ void
tm_format_reltime(char *x, bird_clock_t t)
{
struct tm *tm;
- bird_clock_t delta = now - t;
+ bird_clock_t delta = (t < now) ? (now - t) : (t - now);
static char *month_names[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
tm = localtime(&t);
- if (delta < 0)
- strcpy(x, "?fut?");
- else if (delta < 20*3600)
+ if (delta < 20*3600)
bsprintf(x, "%02d:%02d", tm->tm_hour, tm->tm_min);
else if (delta < 360*86400)
bsprintf(x, "%s%02d", month_names[tm->tm_mon], tm->tm_mday);