2007-06-17 19:09:05 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
|
|
|
* Utility routines.
|
|
|
|
*
|
2008-03-02 12:53:15 +00:00
|
|
|
* Copyright (C) 2007 Denys Vlasenko
|
2007-06-17 19:09:05 +00:00
|
|
|
*
|
2010-08-16 20:14:46 +02:00
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
2007-06-17 19:09:05 +00:00
|
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
|
|
|
2014-11-05 18:00:35 -06:00
|
|
|
#ifndef __GNO__
|
2009-07-18 03:41:29 +02:00
|
|
|
|
2013-03-29 12:30:33 +01:00
|
|
|
static char* strftime_fmt(char *buf, unsigned len, time_t *tp, const char *fmt)
|
|
|
|
{
|
|
|
|
time_t t;
|
|
|
|
if (!tp) {
|
|
|
|
tp = &t;
|
|
|
|
time(tp);
|
|
|
|
}
|
|
|
|
/* Returns pointer to NUL */
|
|
|
|
return buf + strftime(buf, len, fmt, localtime(tp));
|
|
|
|
}
|
|
|
|
|
|
|
|
char* FAST_FUNC strftime_HHMMSS(char *buf, unsigned len, time_t *tp)
|
|
|
|
{
|
|
|
|
return strftime_fmt(buf, len, tp, "%H:%M:%S");
|
|
|
|
}
|
|
|
|
|
|
|
|
char* FAST_FUNC strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp)
|
|
|
|
{
|
|
|
|
return strftime_fmt(buf, len, tp, "%Y-%m-%d %H:%M:%S");
|
|
|
|
}
|
|
|
|
|
2014-11-05 18:00:35 -06:00
|
|
|
#endif
|
|
|
|
|
2014-10-27 19:45:38 -05:00
|
|
|
unsigned long FAST_FUNC monotonic_sec(void)
|
2007-06-17 23:40:26 +00:00
|
|
|
{
|
|
|
|
return time(NULL);
|
|
|
|
}
|