Convert aweek objects to characters or dates

# S3 method for aweek
as.Date(x, floor_day = FALSE, ...)

# S3 method for aweek
as.POSIXlt(x, tz = "", floor_day = FALSE, ...)

# S3 method for aweek
as.character(x, ...)

Arguments

x

an object of class aweek.

floor_day

when TRUE, the days will be set to the start of the week.

...

parameters passed to as.POSIXlt().

tz

passed on to as.POSIXlt()

See also

Examples

w <- date2week(Sys.Date(), week_start = "Sunday") w
#> <aweek start: Sunday> #> [1] "2021-W12-1"
# convert to POSIX as.POSIXlt(w)
#> [1] "2021-03-21 UTC"
as.POSIXlt(w, floor_day = TRUE)
#> [1] "2021-03-21 UTC"
as.POSIXlt(w, floor_day = TRUE, tz = "KST")
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> Warning: unknown timezone 'KST'
#> [1] "2021-03-21 GMT"
# convert to date as.Date(w)
#> [1] "2021-03-21"
as.Date(w, floor_day = TRUE)
#> [1] "2021-03-21"
# convert to character (strip attributes) as.character(w)
#> [1] "2021-W12-1"