diff options
author | Thomas Weißschuh <thomas@t-8ch.de> | 2023-01-06 14:36:37 +0000 |
---|---|---|
committer | Thomas Weißschuh <thomas@t-8ch.de> | 2023-01-06 14:37:55 +0000 |
commit | 937cd872a987a9a69f6a075c7ea9d594d9858d99 (patch) | |
tree | 291a74a91e8cc7b4d331cafd530c436ec630aab2 /lib | |
parent | 3145da8887258de0f5683142f9a3e64d2b3216cc (diff) | |
download | util-linux-937cd872a987a9a69f6a075c7ea9d594d9858d99.tar.gz |
strutils: add function strtotimespec_or_err
Diffstat (limited to 'lib')
-rw-r--r-- | lib/strutils.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/strutils.c b/lib/strutils.c index 6d863b85f..f6f299db4 100644 --- a/lib/strutils.c +++ b/lib/strutils.c @@ -500,6 +500,15 @@ void strtotimeval_or_err(const char *str, struct timeval *tv, const char *errmes tv->tv_usec = (suseconds_t)((user_input - tv->tv_sec) * 1000000); } +void strtotimespec_or_err(const char *str, struct timespec *ts, const char *errmesg) +{ + long double user_input; + + user_input = strtold_or_err(str, errmesg); + ts->tv_sec = (time_t) user_input; + ts->tv_nsec = (long)((user_input - ts->tv_sec) * 1000000000); +} + time_t strtotime_or_err(const char *str, const char *errmesg) { int64_t user_input; |