From 8bb05ac73a5b448b339ce0bc8d396c82c459b47f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 21:33:32 +0200 Subject: Merging upstream version 2.40. Signed-off-by: Daniel Baumann --- include/timeutils.h | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'include/timeutils.h') diff --git a/include/timeutils.h b/include/timeutils.h index a195df8..27261ab 100644 --- a/include/timeutils.h +++ b/include/timeutils.h @@ -18,6 +18,7 @@ #include #include #include +#include typedef uint64_t usec_t; typedef uint64_t nsec_t; @@ -56,8 +57,10 @@ enum { ISO_TIMEZONE = (1 << 2), ISO_DOTUSEC = (1 << 3), ISO_COMMAUSEC = (1 << 4), - ISO_T = (1 << 5), - ISO_GMTIME = (1 << 6), + ISO_DOTNSEC = (1 << 5), + ISO_COMMANSEC = (1 << 6), + ISO_T = (1 << 7), + ISO_GMTIME = (1 << 8), ISO_TIMESTAMP = ISO_DATE | ISO_TIME | ISO_TIMEZONE, ISO_TIMESTAMP_T = ISO_TIMESTAMP | ISO_T, ISO_TIMESTAMP_DOT = ISO_TIMESTAMP | ISO_DOTUSEC, @@ -71,9 +74,11 @@ enum { #define CTIME_BUFSIZ 26 #define ISO_BUFSIZ 42 -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 strtimeval_iso(const struct timeval *tv, int flags, char *buf, size_t bufsz); +int strtm_iso(const struct tm *tm, int flags, char *buf, size_t bufsz); int strtime_iso(const time_t *t, int flags, char *buf, size_t bufsz); +int strtimespec_iso(const struct timespec *t, int flags, char *buf, size_t bufsz); +int strtimespec_relative(const struct timespec *ts, char *buf, size_t bufsz); #define UL_SHORTTIME_THISYEAR_HHMM (1 << 1) @@ -102,4 +107,9 @@ static inline struct timeval usec_to_timeval(usec_t t) return r; } +static inline bool is_timespecset(const struct timespec *t) +{ + return t->tv_sec || t->tv_nsec; +} + #endif /* UTIL_LINUX_TIME_UTIL_H */ -- cgit v1.2.3