Skip to contents

Coerces a time object (e.g. Date, POSIXct, yearmonth) to a mixtime vector using vctrs::vec_cast(). The chronon and cycle are inferred from x via time_chronon() and time_cycle().

Usage

as_mixtime(x, ...)

Arguments

x

A time value to convert to a mixtime. Any time class with a defined time_chronon() method can be converted (e.g. Date, POSIXct, yearmonth, etc.).

...

Additional arguments passed to the underlying vctrs::vec_cast() method.

Value

A mixtime object corresponding to x.

See also

mixtime() for constructing a mixtime directly from data, is_mixtime() for testing if an object is a mixtime.

Examples

as_mixtime(Sys.Date())
#> <mixtime[1]>
#> [1] 2026-04-08
as_mixtime(Sys.time())
#> <mixtime[1]>
#> [1] 2026-04-08 03:06:05