X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Ftiming%2Ftimestamp.cxx;h=83eff2fc10ea485c8039634132b958f1ac866cef;hb=b47d1ad5fd8ed111cae99c1f65f5bb65a5371501;hp=4d14a42acc16ed733b54b80d3fe76c26bd222383;hpb=f1f0fa0aa95c2f1562fa9c09365baf8b2b55bfc7;p=simgear.git diff --git a/simgear/timing/timestamp.cxx b/simgear/timing/timestamp.cxx index 4d14a42a..83eff2fc 100644 --- a/simgear/timing/timestamp.cxx +++ b/simgear/timing/timestamp.cxx @@ -59,11 +59,11 @@ #include "timestamp.hxx" void SGTimeStamp::stamp() { -#if defined( WIN32 ) && !defined(__CYGWIN__) +#ifdef _WIN32 unsigned int t; t = timeGetTime(); _sec = t / 1000; - _nsec = ( t - ( seconds * 1000 ) ) * 1000 * 1000; + _nsec = ( t - ( _sec * 1000 ) ) * 1000 * 1000; #elif defined(_POSIX_TIMERS) && (0 < _POSIX_TIMERS) struct timespec ts; #if defined(_POSIX_MONOTONIC_CLOCK) @@ -104,3 +104,10 @@ void SGTimeStamp::stamp() { #endif } +int SGTimeStamp::elapsedMSec() const +{ + SGTimeStamp now; + now.stamp(); + + return static_cast((now - *this).toMSecs()); +}