Permalink
Browse files

changed from adding seconds to adding ticks, since the resolution get…

…s truncated to milliseconds when adding seconds to a date time, thanks to @dlbromen for pointing this out in issue #66
  • Loading branch information...
nberardi committed Sep 21, 2012
1 parent 50617a7 commit 5bb2c693d173d655bb3a5ec4693d1fc336bc0e95
Showing with 4 additions and 1 deletion.
  1. +4 −1 src/System/DateTimePrecise.cs
@@ -28,6 +28,8 @@ public static DateTimeOffset UtcNowOffset
get { return Instance.GetUtcNow(); }
}
+ private const int TicksInOneSecond = 10000000;
+
private readonly double _syncSeconds;
private readonly Stopwatch _stopwatch;
private DateTimeOffset _baseTime;
@@ -57,7 +59,8 @@ public DateTimeOffset GetUtcNow()
return _baseTime;
}
- return _baseTime.AddSeconds(elapsedSeconds);
+ var elapsedTicks = Convert.ToInt64(elapsedSeconds * TicksInOneSecond);
+ return _baseTime.AddTicks(elapsedTicks);
}
}
}

0 comments on commit 5bb2c69

Please sign in to comment.