mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
tm_format_reltime() works with both past and future timestamps.
This commit is contained in:
parent
c23f40b145
commit
b594ad2386
@ -305,13 +305,11 @@ void
|
|||||||
tm_format_reltime(char *x, bird_clock_t t)
|
tm_format_reltime(char *x, bird_clock_t t)
|
||||||
{
|
{
|
||||||
struct tm *tm;
|
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" };
|
static char *month_names[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
|
||||||
|
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
if (delta < 0)
|
if (delta < 20*3600)
|
||||||
strcpy(x, "?fut?");
|
|
||||||
else if (delta < 20*3600)
|
|
||||||
bsprintf(x, "%02d:%02d", tm->tm_hour, tm->tm_min);
|
bsprintf(x, "%02d:%02d", tm->tm_hour, tm->tm_min);
|
||||||
else if (delta < 360*86400)
|
else if (delta < 360*86400)
|
||||||
bsprintf(x, "%s%02d", month_names[tm->tm_mon], tm->tm_mday);
|
bsprintf(x, "%s%02d", month_names[tm->tm_mon], tm->tm_mday);
|
||||||
|
Loading…
Reference in New Issue
Block a user