Revision afa8937a

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
 */
sysdep/unix/timer.h
35 35
bird_clock_t tm_parse_date(char *);	/* Convert date to bird_clock_t */
36 36
void tm_format_date(char *, bird_clock_t);	/* Convert bird_clock_t to date */
37 37
#define TM_DATE_BUFFER_SIZE 12		/* Buffer size required by tm_format_date */
38
void tm_format_reltime(char *, bird_clock_t);	/* Convert bird_clock_t to relative datetime string */
39
#define TM_RELTIME_BUFFER_SIZE 12	/* Buffer size required by tm_format_time */
38 40

  
39 41
#ifdef TIME_T_IS_64BIT
40 42
#define TIME_INFINITY 0x7fffffffffffffff

Also available in: Unified diff