mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
Drops the use of `Time.now` in favor of using the system's monotonic clock for various operations that calculate and use elapsed duration. The latter is preferable because in some cases `Time.now` can be unstable, like if it's set manually by a system administrator or an NTP daemon. I don't expect that the previous code would actually have caused trouble in the vast majority of normal situations, so I'm not going to backport anything, but this seems like good hygiene. For better or worse I had to wrap the monotonic time calls in a new `Util` function because (1) the normal invocation is long enough to have caused a lot of overruns on our 80 character line lengths, and (2) Timecop doesn't stub the monotonic clock, so the `Util` method gives us a nice place that we can stub on where necessary.