Skip to contents

This S7 generic function extracts the chronon (the smallest time granule) from a time object, such as continuous time or cyclical time representations.

Usage

time_chronon(x, ...)

Arguments

x

A time object (e.g., base::Date, base::POSIXct, linear_time(), etc.)

...

Additional arguments for methods.

Value

A time granule object representing the chronon (e.g., cal_gregorian$day(1L))

Examples


# The chronon of a Date object is 1 day
time_chronon(Sys.Date())
#> <mixtime::tu_day>
#>  @ n : int 1
#>  @ tz: 'mt_naive' chr NA

# The chronon of a POSIXct object is 1 second
time_chronon(Sys.time())
#> <mixtime::tu_second>
#>  @ n : int 1
#>  @ tz: 'mt_naive' chr NA

# The chronon of a continuous time year and month is 1 month
time_chronon(yearmonth(Sys.Date()))
#> <mixtime::tu_month>
#>  @ n : int 1
#>  @ tz: 'mt_naive' chr NA

# The common chronon of a mixed time object is the finest chronon
time_chronon(c(yearmonth(Sys.Date()), Sys.Date()))
#> <mixtime::tu_day>
#>  @ n : int 1
#>  @ tz: 'mt_naive' chr NA