Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

took @dlbromen advise and just used TimeSpan to simplify the code

  • Loading branch information...
commit da680fb7fb2f9fb23c31ee7cd9f9287aa6805615 1 parent 3733d29
@nberardi nberardi authored
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/System/DateTimePrecise.cs
View
12 src/System/DateTimePrecise.cs
@@ -52,17 +52,17 @@ private void Syncronize()
public DateTimeOffset GetUtcNow()
{
- var elapsedSeconds = _stopwatch.ElapsedTicks / (double)Stopwatch.Frequency;
-
- if (elapsedSeconds > _syncSeconds) {
+ var elapsed = _stopwatch.Elapsed;
+
+ if (elapsed.TotalSeconds > _syncSeconds)
+ {
Syncronize();
// account for any time that has passed since the stopwatch was syncronized
- elapsedSeconds = _stopwatch.ElapsedTicks / (double)Stopwatch.Frequency;
+ elapsed = _stopwatch.Elapsed;
}
- var elapsedTicks = Convert.ToInt64(elapsedSeconds * TicksInOneSecond);
- return _baseTime.AddTicks(elapsedTicks);
+ return _baseTime + elapsed;
}
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.