diff options
author | Hristo Venev <hristo@venev.name> | 2015-11-16 10:15:05 +0200 |
---|---|---|
committer | Hristo Venev <hristo@venev.name> | 2015-11-17 23:52:09 +0200 |
commit | 436dd70f5331ec541ebdd84e106abaa63203f6f1 (patch) | |
tree | aeb12e97a49051979dce893fa1b92bed52ba1153 /src/basic/time-util.c | |
parent | 92939fc4c0261dccd4b755186aba84a9b1412bed (diff) |
calendarspec: sub-second support, v3
Diffstat (limited to 'src/basic/time-util.c')
-rw-r--r-- | src/basic/time-util.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 647763a230..b9da6991da 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -27,6 +27,7 @@ #include "fd-util.h" #include "fileio.h" #include "fs-util.h" +#include "parse-util.h" #include "path-util.h" #include "string-util.h" #include "strv.h" @@ -658,29 +659,18 @@ int parse_timestamp(const char *t, usec_t *usec) { parse_usec: { - char *end; - unsigned long long val; - size_t l; + unsigned add; k++; - if (*k < '0' || *k > '9') + r = parse_fractional_part_u(&k, 6, &add); + if (r < 0) return -EINVAL; - /* base 10 instead of base 0, .09 is not base 8 */ - errno = 0; - val = strtoull(k, &end, 10); - if (*end || errno) + if (*k) return -EINVAL; - l = end-k; - - /* val has l digits, make them 6 */ - for (; l < 6; l++) - val *= 10; - for (; l > 6; l--) - val /= 10; + x_usec = add; - x_usec = val; } from_tm: |