Calculates year, month and the time of day categories based
on input argument x
with respect to the time zone
specified by the user.
Arguments
- x
object of class
POSIXt
.- tz
time zone (character). Important to properly calculate month and time of day.
Examples
x <- as.POSIXct("2022-01-01", tz = "UTC") + 0:10 * 3600
annex:::annex_add_year_month_and_tod(x, tz = "Europe/Berlin")
#> $year
#> [1] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
#> Levels: 2022
#>
#> $month
#> [1] 1 1 1 1 1 1 1 1 1 1 1
#> Levels: all 1 2 3 4 5 6 7 8 9 10 11 12
#>
#> $tod
#> [1] 23-07 23-07 23-07 23-07 23-07 23-07 07-23 07-23 07-23 07-23 07-23
#> Levels: 23-07 07-23
#>
annex:::annex_add_year_month_and_tod(x, tz = "US/Central")
#> $year
#> [1] 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022 2022
#> Levels: 2022
#>
#> $month
#> [1] 1 1 1 1 1 1 1 1 1 1 1
#> Levels: all 1 2 3 4 5 6 7 8 9 10 11 12
#>
#> $tod
#> [1] 23-07 23-07 23-07 23-07 23-07 23-07 23-07 07-23 07-23 07-23 07-23
#> Levels: 23-07 07-23
#>