as_year()
is a generic for coercing input in to <grates_year>
.
Usage
as_year(x, ...)
# Default S3 method
as_year(x, ...)
# S3 method for class 'Date'
as_year(x, ...)
# S3 method for class 'POSIXt'
as_year(x, ...)
# S3 method for class 'character'
as_year(x, ...)
# S3 method for class 'factor'
as_year(x, ...)
Examples
as_year(Sys.Date())
#> <grates_year[1]>
#> [1] 2024
as_year(as.POSIXct("2019-03-04 01:01:01", tz = "America/New_York"), interval = 2)
#> <grates_year[1]>
#> [1] 2019
as_year("2019-05-03")
#> <grates_year[1]>
#> [1] 2019