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 18:14:46 +00:00
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
2007-06-17 19:09:05 +00:00
|
|
|
*/
|
|
|
|
#include "libbb.h"
|
|
|
|
|
2014-11-06 00:00:35 +00:00
|
|
|
#ifndef __GNO__
|
2009-07-18 01:41:29 +00:00
|
|
|
|
2013-03-29 11:30:33 +00: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-06 00:00:35 +00:00
|
|
|
#endif
|
|
|
|
|
2014-10-28 00:45:38 +00:00
|
|
|
unsigned long FAST_FUNC monotonic_sec(void)
|
2007-06-17 23:40:26 +00:00
|
|
|
{
|
|
|
|
return time(NULL);
|
|
|
|
}
|