Skip to content

Commit

Permalink
Use monotonically-increasing time stamps. Fixes #150
Browse files Browse the repository at this point in the history
  • Loading branch information
wch committed Jun 29, 2021
1 parent 9096d0c commit 90a89e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/timestamp_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "timeconv.h"

void get_current_time(timespec *ts) {
timeval tv;
gettimeofday(&tv, NULL);
*ts = timevalToTimespec(tv);
// CLOCK_MONOTONIC ensures that we never get timestamps that go backward in
// time due to clock adjustment. https://github.com/r-lib/later/issues/150
clock_gettime(CLOCK_MONOTONIC, ts);
}

class TimestampImplPosix : public TimestampImpl {
Expand Down

0 comments on commit 90a89e0

Please sign in to comment.