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()
and sys_date()
are drop in replacements for Sys.time()
and Sys.Date()
AND are mockableSee the docs to get started: https://docs.ropensci.org/pendulum/
remotes::install_github("ropensci/pendulum")
library(pendulum)
pendulum
in R doing citation(package = 'pendulum')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.