Merge /u/janodesbois/simgear-jano/ branch mp-merge into next

https://sourceforge.net/p/flightgear/simgear/merge-requests/42/
This commit is contained in:
James Turner
2018-01-22 09:48:01 +00:00
2 changed files with 23 additions and 0 deletions

View File

@@ -29,6 +29,7 @@
#include <ctime>
#include <cerrno>
#include <chrono>
#ifdef HAVE_UNISTD_H
# include <unistd.h> // for gettimeofday() and the _POSIX_TIMERS define
@@ -98,6 +99,21 @@ void SGTimeStamp::stamp()
#endif
}
void SGTimeStamp::systemClockHoursAndMinutes()
{
using namespace std;
using namespace std::chrono;
typedef duration<int, ratio_multiply<hours::period, ratio<24> >::type> days;
system_clock::time_point now = system_clock::now();
system_clock::duration tp = now.time_since_epoch();
tp -= duration_cast<days>(tp);
_sec = duration_cast<seconds>(tp).count();
_nsec = duration_cast<nanoseconds>(tp - seconds(_sec)).count();
}
// sleep based timing loop.
//
// Calling sleep, even usleep() on linux is less accurate than

View File

@@ -78,6 +78,13 @@ public:
/** Update stored time to current time (seconds and nanoseconds) */
void stamp();
/** Update stored time to current system clock (seconds and nanoseconds)
* non monotonic, keeping only hours, minutes, seconds and decimals,
* so restart at 0 at midnight.
* using the std::chrono libs
*/
void systemClockHoursAndMinutes();
/** Set the time from a double value */
void setTime(const double& seconds)
{