]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: time-util - Add support for rounding off timeval to a time_t value.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Thu, 29 Oct 2020 00:09:17 +0000 (01:09 +0100)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 11 Feb 2021 12:23:36 +0000 (12:23 +0000)
src/lib/time-util.h

index 5d95aabd49cecbd2bbb285f8ae69a6d0c444243c..74ae9edf5ea46f16dc0a58d14b15288d1b99607c 100644 (file)
@@ -80,6 +80,11 @@ static inline void timeval_add(struct timeval *tv, const struct timeval *val)
        }
 }
 
+static inline time_t timeval_round(struct timeval *tv)
+{
+       return (tv->tv_usec < 500000 ? tv->tv_sec : tv->tv_sec + 1);
+}
+
 /* Convert t to local time and return timestamp on that day at 00:00:00. */
 time_t time_to_local_day_start(time_t t);