From a11b1c104f96c803b62e9eca5cfc06fafaa9a422 Mon Sep 17 00:00:00 2001 From: Nikita Kniazev Date: Tue, 12 May 2020 15:31:33 +0300 Subject: [PATCH] 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 --- src/engine/timestamp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/engine/timestamp.cpp b/src/engine/timestamp.cpp index 67090ca55..fe9947642 100644 --- a/src/engine/timestamp.cpp +++ b/src/engine/timestamp.cpp @@ -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; }