Revision afa8937a sysdep/unix/io.c

View differences:

sysdep/unix/io.c
27 27
#include "lib/timer.h"
28 28
#include "lib/socket.h"
29 29
#include "lib/event.h"
30
#include "lib/string.h"
30 31
#include "nest/iface.h"
31 32

  
32 33
#ifdef IPV6
......
253 254
  sprintf(x, "%02d-%02d-%04d", tm->tm_mday, tm->tm_mon+1, tm->tm_year+1900);
254 255
}
255 256

  
257
void
258
tm_format_reltime(char *x, bird_clock_t t)
259
{
260
  struct tm *tm;
261
  bird_clock_t delta = now - t;
262
  static char *month_names[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" };
263

  
264
  tm = localtime(&t);
265
  if (delta < 0)
266
    strcpy(x, "?fut?");
267
  else if (delta < 20*3600)
268
    bsprintf(x, "%02d:%02d", tm->tm_hour, tm->tm_min);
269
  else if (delta < 360*86400)
270
    bsprintf(x, "%s%02d", month_names[tm->tm_mon], tm->tm_mday);
271
  else
272
    bsprintf(x, "%d", tm->tm_year+1900);
273
}
274

  
256 275
/*
257 276
 *	Sockets
258 277
 */

Also available in: Unified diff