clock_mock: Mock time

View source: R/clock_mock.R

clock_mockR Documentation

Mock time

Description

Mock time

Usage

clock_mock(on = TRUE)

Arguments

on

(logical) turn mocking on with TRUE or turn off with FALSE. By default is FALSE

Details

timefuzz package required for mocking behavior

Examples

## Not run: 

if (interactive()) {
  # load timefuzz
  library(timefuzz)
  library(clock)

  # turn on mocking
  clock_mock()

  # do stuff
  x <- time_fuzz$new()
  ## set to today + 435 days
  x$freeze(Sys.Date() + 435)

  # get time again
  now()

  # turn off mocking
  clock_mock(FALSE)

  # get time again
  now()
}


## End(Not run)

ropensci/clock documentation built on Sept. 11, 2022, 11:07 a.m.