conditional_run: Run code if time has elapsed

Description Usage Arguments See Also Examples

Description

a common operation is needing to run queries to update a file-based dataset after N (days, hours, minutes) have elapsed. iftime and ifdate are simple conditionals that evaluate an expression if and only if a certain time period has passed since a provided baseline.

Usage

1
2
3
iftime(baseline, offset, expr)

ifdate(baseline, offset, expr)

Arguments

baseline

the baseline - the time we're checking the current time against

offset

the amount of time that should have elapsed since baseline for the expression to be evaluated

expr

an expression to be evaluated if baseline + offset >= current time

See Also

timehandlers for other time handlers.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#Use time. If it's been 20 seconds since the
## Not run: 
baseline, run.
baseline_time <- Sys.time() - 20
iftime(baseline = baseline_time, offset = 20,
expr = {
print("Baaaah")
})
#[1] "Baaaah"

#Use dates. If it's been 30 days since the
baseline, run.
baseline_date <- Sys.Date() - 30
ifdate(baseline = baseline_time, offset = 30,
expr = {
print("Baaaah")
})
#[1] "Baaaah"

## End(Not run)

Ironholds/olivr documentation built on May 7, 2019, 6:40 a.m.