max_cycle_length: Calculate the Maximum Possible Value of a Time Cycle

View source: R/convert_date_to_numeric.R

max_cycle_lengthR Documentation

Calculate the Maximum Possible Value of a Time Cycle

Description

This function returns the maximum possible value that a specific time component can take, given a cycle length and scale.

Usage

max_cycle_length(cycle_length, time_scale)

Arguments

cycle_length

A character string indicating the larger unit of time. It must be one of "year", "month", "day", "hour", "minute".

time_scale

A character string indicating the smaller unit of time, which is a division of the cycle_length. If cycle_length is "year", time_scale can be one of "month", "day", "hour", "minute", "second". If cycle_length is "month", time_scale can be "day", "hour", "minute", "second", and so on.

Value

The function returns the maximum possible value that the time_scale can take within one cycle_length.

Examples


max_cycle_length("year", "month")  # Maximum months is a year 12
max_cycle_length("day", "minute")  # Maximum minutes in a day 1440
max_cycle_length("year", "day")    # Maximum days in a year 366


twdtw documentation built on Aug. 8, 2023, 9:06 a.m.