| time_fuzz | R Documentation |
time_fuzz
Methods
freeze(...)Freeze time
an time_fuzz object
## Not run:
x <- time_fuzz$new()
x
x$date
x <- time_fuzz$new()
x
x$freeze
x$freeze("2019-01-29", {
5 + 5
})
x$scale
x$scale({
5 + 5
})
library(timefuzz)
library(clock)
library(testthat)
# pendulum::clock_mock()
pendulum:::clock_opts$mock
(cl <- clock())
book_due <- function(due_date = "2020-08-25") {
as.POSIXct(pendulum::clock()$date()) > as.POSIXct(due_date)
}
expect_false(book_due()) # FALSE
x <- time_fuzz$new()
x
x$freeze(Sys.Date() + 60, {
# pendulum::clock_mock()
# cat(pendulum:::clock_opts$mock, sep = "\n")
# cat(as.character(pendulum::clock()$date()), sep = "\n")
# cat(pendulum:::clock_opts$mock, sep = "\n")
expect_true(book_due())
})
# no block passed
clock_mock()
clock()$now()
Sys.time()
x <- time_fuzz$new()
## set to today + 435 days
x$freeze(Sys.Date() + 435)
pendulum:::clock_opts$mock
clock()$now()
x$unfreeze()
pendulum:::clock_opts$mock
clock()$now()
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.