View source: R/derive_vars_dt_dtm_utils.R
is_partial_datetime | R Documentation |
This function determines whether a given partial date/time structure represents a datetime or just a date.
is_partial_datetime(partial)
partial |
A named list containing date or datetime components.
|
The function checks for the presence of all date components (year, month, day) and all time components (hour, minute, second) in the input list. If all components are present, it's considered a datetime. If only date components are present, it's considered a date. Any other combination will result in an error.
A logical value. TRUE if the partial represents a datetime, FALSE if it represents a date only.
# Datetime example
partial_datetime <- list(
year = "2023", month = "05", day = "15",
hour = "14", minute = "30", second = "00"
)
admiral:::is_partial_datetime(partial_datetime) # Returns TRUE
# Date example
partial_date <- list(year = "2023", month = "05", day = "15")
admiral:::is_partial_datetime(partial_date) # Returns FALSE
# Invalid example
## Not run:
partial_invalid <- list(year = "2023", month = "05", hour = "14")
admiral:::is_partial_datetime(partial_invalid) # Throws an error
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.