Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Latest commit

 

History

History
39 lines (24 loc) · 1.83 KB

File metadata and controls

39 lines (24 loc) · 1.83 KB

pendulum

Project Status: Active – The project has reached a stable, usable state and is being actively developed. R-check

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 time
  • now() is designed for getting the current time AND is mockable
  • sys_time() and sys_date() are drop in replacements for Sys.time() and Sys.Date() AND are mockable

See the docs to get started: https://docs.ropensci.org/pendulum/

Installation

remotes::install_github("ropensci/pendulum")
library(pendulum)

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for pendulum in R doing citation(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.