aboutsummaryrefslogtreecommitdiff
path: root/libbb/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/time.c')
-rw-r--r--libbb/time.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/libbb/time.c b/libbb/time.c
index e2b938471..57e14b66c 100644
--- a/libbb/time.c
+++ b/libbb/time.c
@@ -187,6 +187,27 @@ time_t FAST_FUNC validate_tm_time(const char *date_str, struct tm *ptm)
187 return t; 187 return t;
188} 188}
189 189
190static char* strftime_fmt(char *buf, unsigned len, time_t *tp, const char *fmt)
191{
192 time_t t;
193 if (!tp) {
194 tp = &t;
195 time(tp);
196 }
197 /* Returns pointer to NUL */
198 return buf + strftime(buf, len, fmt, localtime(tp));
199}
200
201char* FAST_FUNC strftime_HHMMSS(char *buf, unsigned len, time_t *tp)
202{
203 return strftime_fmt(buf, len, tp, "%H:%M:%S");
204}
205
206char* FAST_FUNC strftime_YYYYMMDDHHMMSS(char *buf, unsigned len, time_t *tp)
207{
208 return strftime_fmt(buf, len, tp, "%Y-%m-%d %H:%M:%S");
209}
210
190#if ENABLE_MONOTONIC_SYSCALL 211#if ENABLE_MONOTONIC_SYSCALL
191 212
192#include <sys/syscall.h> 213#include <sys/syscall.h>