3 ms·
* in C++. On Python, just use freezegun to inject controllable timestamps in response to calls to time methods. https://github.com/spulec/freezegun https://gi
by loloquwowndueo 3y ago
* in C++.
On Python, just use freezegun to inject controllable timestamps in response to calls to time methods.
https://github.com/spulec/freezegun https://github.com/spulec/freezegun
- boxed 3y agoFreezegun is pretty much unmaintained. You want time-machine https://github.com/adamchainz/time-machine https://github.com/adamchainz/time-machine
- pmontra 3y agoThe Ruby equivalent is Timecop https://github.com/travisjeffery/timecop https://github.com/travisjeffery/timecop Dynamic languages have the advantage to be able to rewrite the standard library classes at runtime.
- sroussey 3y agoI used to change an objects class itself in runtime in JS by changing its __proto__ property. I don’t think that works anymore, but at the time I could create plain value objects and later make them class instantiations (on a small system way back when, this was a nice speed up due to a now uncommon pattern of having data first and waiting for the classes to load).
- Brybry 3y agoOther languages can use LD_PRELOAD (or DLL injection on Windows) as long as the binary isn't statically linked. See other comments in the thread about libfaketime.
- pmontra 3y agoI read the documentation about libfaketime and I saw that it doesn't work in combination with other libraries that also play with LD_PRELOAD. Timecop could fail if something else also wraps the date and time classes but its block scoped form should keep working. I didn't check. Furthermore I don't know what's out there that does it. I should write my own code.