Convert between chronons
chronon_convert(x, ...)
A linear time object (of class mt_linear
)
The target chronon to convert to (a time unit object)
If TRUE
, the number of target chronons since Unix epoch
that x
falls into is returned as an integer. If FALSE
, a fractional
number of target chronons is returned (analagous to time using a continuous
time model).
A numeric or integer representing the time since Unix epoch in terms of the target chronon's precision.
# Convert from months since epoch to years since epoch
chronon_convert(yearmonth(Sys.Date()), tu_year(1L))
#> Error in loadNamespace(x): there is no package called ‘vecvec’
# Convert from days since epoch to months since epoch
chronon_convert(Sys.Date(), tu_month(1L))
#> [1] 668.5161
chronon_convert(Sys.Date(), tu_month(1L), discrete = TRUE)
#> [1] 668
# Convert from seconds since epoch to hours since epoch
chronon_convert(Sys.time(), tu_hour(1L))
#> Error in if (start == end) { return(start)}: missing value where TRUE/FALSE needed