diff options
Diffstat (limited to 'source4/lib/time.c')
-rw-r--r-- | source4/lib/time.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/source4/lib/time.c b/source4/lib/time.c index 65b85b2180..ba650668c5 100644 --- a/source4/lib/time.c +++ b/source4/lib/time.c @@ -428,21 +428,31 @@ NTTIME pull_nttime(void *base, uint16 offset) return ret; } +/* + convert a NTTIME to a double in 100-nano-seconds since 1601 +*/ +double nttime_to_double_nt(NTTIME t) +{ + const double t32 = 4294967296.0; + return t.high*t32 + t.low; +} /* - parse a nttime as a integer in a string and return a NTTIME + convert a double in 100-nano-seconds since 1601 to a NTTIME */ -NTTIME nttime_from_string(const char *s) +NTTIME nttime_from_double_nt(double t) { - double t = 0; const double t32 = 4294967296.0; NTTIME ret; - /* i wish we could rely on 64 bit systems and sscanf %llu */ - if (sscanf(s, "%lf", &t) != 1) { - ret.low = 0; - ret.high = 0; - } ret.high = t / t32; ret.low = t - (ret.high*t32); return ret; } + +/* + parse a nttime as a large integer in a string and return a NTTIME +*/ +NTTIME nttime_from_string(const char *s) +{ + return nttime_from_double_nt(strtod(s, NULL)); +} |