2
0
mirror of https://github.com/boostorg/build.git synced 2026-02-12 12:02:24 +00:00

Fix timestamp_delta_seconds (#603)

* The multiplier 1000000 is wrong
* Return seconds as function name and description says
* Use `difftime` instead of assuming `time_t` is in seconds
This commit is contained in:
Nikita Kniazev
2020-05-12 15:31:33 +03:00
committed by GitHub
parent fecf350ce8
commit a11b1c104f

View File

@@ -6,6 +6,7 @@
/* This file is ALSO:
* Copyright 2001-2004 David Abrahams.
* Copyright 2020 Nikita Kniazev.
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or
* http://www.boost.org/LICENSE_1_0.txt)
@@ -226,5 +227,5 @@ void timestamp_done()
*/
double timestamp_delta_seconds( timestamp const * const a , timestamp const * const b )
{
return ((b->secs*1000000.0+b->nsecs)-(a->secs*1000000.0+a->nsecs))/1000000.0;
return difftime(b->secs, a->secs) + (b->nsecs - a->nsecs) * 1.0E-9;
}