Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use lubridate::as_datetime in get_timeseries_signature_date function #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BradThymesAtTheElRoyale

The lubridate::as_date() function relies on the user's timezone, which causes some issues with retrieving the week of the month at the beginning or end of a month when getting the time series signature. Switching to lubridate::as_datetime() solves this issue and returns the expected week of the month. Reprex included below.

Sys.setenv(TZ = 'America/Chicago')
stringi::stri_datetime_fields(lubridate::as_date('2022-11-01'))
#>   Year Month Day Hour Minute Second Millisecond WeekOfYear WeekOfMonth
#> 1 2022    10  31   19      0      0           0         45           6
#>   DayOfYear DayOfWeek Hour12 AmPm Era
#> 1       304         2      7    2   2
stringi::stri_datetime_fields(lubridate::as_datetime('2022-11-01'))
#>   Year Month Day Hour Minute Second Millisecond WeekOfYear WeekOfMonth
#> 1 2022    11   1    0      0      0           0         45           1
#>   DayOfYear DayOfWeek Hour12 AmPm Era
#> 1       305         3      0    1   2

Created on 2023-05-10 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant