timecop icon indicating copy to clipboard operation
timecop copied to clipboard

Raise an exception if this arg looks like a timestamp

Open shalecraig opened this issue 7 years ago • 1 comments

In the case where someone calls Timecop.freeze(some_timestamp), they probably meant to freeze at the provided timestamp, instead of that many seconds in the future.

I don't think I'd want to ship this PR, but can massage this PR into whichever of these you prefer:

  1. if arg > k, using that timestamp
  2. if arg > k, materializing an exception that can be caught
  3. Something else?

k

I chose 1300000000 somewhat arbitrarily. Happy to change it to something like 1000000000 instead.

Tests

Happy to write tests once you let me know which outcome you prefer.

shalecraig avatar Dec 22 '17 02:12 shalecraig

they probably meant ...

I chose 1300000000 somewhat arbitrarily ...

:-1: It's a nice idea, but I don't think this should be merged...

This patch may be useful for your specific use case, but I don't think the gem should be "cluttered" with this hardcoded value, or even as a configuration option.

If you passed a timestamp into the method, then that's a bug in your code; not a bug in TimeCop.

tom-lord avatar Jan 22 '18 14:01 tom-lord