Time classes for R, w/ time mocking capability via timefuzz
Why? - Some programming languages support monkey patching. However, R does not officially allow this (there's a way to do it, but it's a hack). Therefore, the only way that I can think of to "mock time" is to use a different set of time classes/objects. That is, we can't just mock time using Sys.Date() directly as there's no way to monkey patch the code behind that function. Some may say it's good that R doesn't officially support monkey patching; there's definitely upsides; but a downside is that mocking things like time becomes difficult.
clock()is designed for setting a specific timenow()is designed for getting the current time AND is mockablesys_time()andsys_date()are drop in replacements forSys.time()andSys.Date()AND are mockable
See the docs to get started: https://docs.ropensci.org/pendulum/
remotes::install_github("ropensci/pendulum")library(pendulum)- Please report any issues or bugs.
- License: MIT
- Get citation information for
pendulumin R doingcitation(package = 'pendulum') - Please note that this package is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.