diff options
author | Karel Zak | 2016-05-24 10:58:52 +0200 |
---|---|---|
committer | Karel Zak | 2016-05-24 10:58:52 +0200 |
commit | 33c7ffa3039511384012296d05a9f227269f7797 (patch) | |
tree | 8767b2a41f3a7f44ece913879d34f39c9c59b5cc /include/timeutils.h | |
parent | include/timeutils: use pointer for time_t (diff) | |
download | kernel-qcow2-util-linux-33c7ffa3039511384012296d05a9f227269f7797.tar.gz kernel-qcow2-util-linux-33c7ffa3039511384012296d05a9f227269f7797.tar.xz kernel-qcow2-util-linux-33c7ffa3039511384012296d05a9f227269f7797.zip |
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 <kzak@redhat.com>
Diffstat (limited to 'include/timeutils.h')
-rw-r--r-- | include/timeutils.h | 16 |
1 files changed, 10 insertions, 6 deletions
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 */ |