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

as.Date does not handle the case where tz is a vector #118

Closed
lsilvest opened this issue Sep 7, 2023 · 5 comments · Fixed by #119
Closed

as.Date does not handle the case where tz is a vector #118

lsilvest opened this issue Sep 7, 2023 · 5 comments · Fixed by #119

Comments

@lsilvest
Copy link
Collaborator

lsilvest commented Sep 7, 2023

We handle tz as a vector it correctly in the extract functions (nano_month, etc.), but in our as.Date we convert first to POSIXct and then call the base as.Date . So the idea here is to use our own functions instead of relying on POSIXct.

@eddelbuettel
Copy link
Owner

Could do. Do you have a use case for that?

@lsilvest
Copy link
Collaborator Author

Yes, I recently had a set of observations over a couple of months with UTC times, all with different geographical locations and needed to group the observations by day. I converted the geographical locations to timezones, but couldn't directly use nanotime's as.Date as it doesn't accept a vector of timezones. Got out of trouble with nano_month, etc., but we could easily fix our as.Date to handle that out of the box.

@eddelbuettel
Copy link
Owner

eddelbuettel commented Sep 10, 2023

Do you have a clever idea for how to do 'maybe-vectorization' ? Or maybe we already do elsewhere? (Asking because I thought 20 years ago it was an important feature over several args so I did a pretty ham-fisted set of nested loop and always wondered about 'better' way....)

@lsilvest
Copy link
Collaborator Author

Fortunately, we've already got some vectorization for this at C level, so it turns out to be fairly straightforward. See if this new code seems OK to you.

@eddelbuettel
Copy link
Owner

Really nice. I had one gut-instinct idea now but not strong feeling either way. With/without automagic tz works for me.

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 a pull request may close this issue.

2 participants