From 33c7ffa3039511384012296d05a9f227269f7797 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 24 May 2016 10:58:52 +0200 Subject: include/timeutils: rewrite iso formatting functions - use buffers rather than allocate memory - support .usec and ,usec convention - use strftime for timezone (we need to care about daylight saving time) Signed-off-by: Karel Zak --- include/timeutils.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'include/timeutils.h') diff --git a/include/timeutils.h b/include/timeutils.h index a1cd1b353..2ec193a09 100644 --- a/include/timeutils.h +++ b/include/timeutils.h @@ -58,12 +58,16 @@ int parse_timestamp(const char *t, usec_t *usec); 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) + ISO_8601_DOTUSEC = (1 << 3), + ISO_8601_COMMAUSEC = (1 << 4), + ISO_8601_TIMEZONE = (1 << 5), + ISO_8601_SPACE = (1 << 6) }; -char *strtimeval_iso(struct timeval *tv, int flags); -char *strtm_iso(struct tm *tm, int flags); -char *strtime_iso(const time_t *t, int flags); + +#define ISO_8601_BUFSIZ 32 + +int strtimeval_iso(struct timeval *tv, int flags, char *buf, size_t bufsz); +int strtm_iso(struct tm *tm, int flags, char *buf, size_t bufsz); +int strtime_iso(const time_t *t, int flags, char *buf, size_t bufsz); #endif /* UTIL_LINUX_TIME_UTIL_H */ -- cgit v1.2.3-55-g7522