From 3c201431ee26c85b5c7fbcd85856c1df84065d64 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 11 May 2016 15:31:02 +0200 Subject: lib/timeutils: add strxxx_iso() functions Signed-off-by: Karel Zak --- include/strutils.h | 2 ++ include/timeutils.h | 13 +++++++++++++ 2 files changed, 15 insertions(+) (limited to 'include') diff --git a/include/strutils.h b/include/strutils.h index 9f4339f41..f303450f5 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -212,6 +212,8 @@ static inline size_t ltrim_whitespace(unsigned char *str) extern char *strnappend(const char *s, const char *suffix, size_t b); extern char *strappend(const char *s, const char *suffix); +extern char *strfappend(const char *s, const char *format, ...) + __attribute__ ((__format__ (__printf__, 2, 0))); extern const char *split(const char **state, size_t *l, const char *separator, int quoted); extern int skip_fline(FILE *fp); diff --git a/include/timeutils.h b/include/timeutils.h index 8ed501b9d..4b6098ae1 100644 --- a/include/timeutils.h +++ b/include/timeutils.h @@ -23,6 +23,7 @@ #include #include +#include typedef uint64_t usec_t; typedef uint64_t nsec_t; @@ -53,4 +54,16 @@ typedef uint64_t nsec_t; int parse_timestamp(const char *t, usec_t *usec); +/* flags for strxxx_iso() functions */ +enum { + ISO_8601_DATE = (1 << 1), + ISO_8601_TIME = (1 << 2), + ISO_8601_USEC = (1 << 3), + ISO_8601_TIMEZONE = (1 << 4), + ISO_8601_SPACE = (1 << 5) +}; +char *strtimeval_iso(struct timeval *tv, int flags); +char *strtm_iso(struct tm *tm, int flags); +char *strtime_iso(time_t t, int flags); + #endif /* UTIL_LINUX_TIME_UTIL_H */ -- cgit v1.2.3-55-g7522