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

month() and otehrs fail on objects from class 'timeDate' #1150

Open
GeoBosh opened this issue Dec 28, 2023 · 0 comments
Open

month() and otehrs fail on objects from class 'timeDate' #1150

GeoBosh opened this issue Dec 28, 2023 · 0 comments

Comments

@GeoBosh
Copy link

GeoBosh commented Dec 28, 2023

A number of functions, such as month() and wday(), are documented to work on objects from class 'timeDate' (from package 'timeDate') but some throw warnings:

lubridate::month(timeDate::timeDate("2023-12-21"))
## [1] 12
## Warning message:
## tz(): Don't know how to compute timezone for object of class timeDate; returning "UTC". 

lubridate::wday(timeDate::timeDate("2023-12-21"))
## [1] 5
## Warning message:
## tz(): Don't know how to compute timezone for object of class timeDate; returning "UTC". 

Also, there is a timeSeries method for tz but it is wrong:

## wrong
lubridate:::tz.timeSeries 
function (x) 
{
    tz(x@FinCenter)  # should be just `x@FinCenter`
}

Both can be fixed by setting:

tz.timeDate <- tz.timeSeries <- function (x) {
    x@FinCenter
}

and registering tz.timeDate (tz.timeSeries is already registered).

tz(as.POSIXlt(1:10, tz = "America/New_York"))
## [1] "America/New_York"

lubridate::tz(timeDate(as.POSIXlt(1:10, tz = "America/New_York"), FinCenter = "America/New_York" ))
## expect after fix: "America/New_York" 

lubridate::tz(timeSeries::timeSeries(1:10, FinCenter = "America/New_York"))
## expect after fix:  "America/New_York" 
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

No branches or pull requests

1 participant