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

[FEA] convert_datetime.cu should use proper chrono types for timestamp/duration handling #9812

Closed
jrhemstad opened this issue Dec 1, 2021 · 4 comments
Labels
feature request New feature or request libcudf Affects libcudf (C++/CUDA) code.

Comments

@jrhemstad
Copy link
Contributor

Is your feature request related to a problem? Please describe.

The functionality in convert_datetime.cu parses timestamps using plain integers instead of chrono types. This should be avoided as it leads to problems like this: #9793

Describe the solution you'd like

Use appropriate chrono types and functions

@github-actions
Copy link

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@github-actions
Copy link

github-actions bot commented Feb 3, 2022

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.

@github-actions
Copy link

github-actions bot commented May 4, 2022

This issue has been labeled inactive-90d due to no recent activity in the past 90 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

@davidwendt
Copy link
Contributor

It appears the chrono classes do not handle negative timestamps

// Note: Tried using: cuda::std::chrono::hh_mm_ss(T::duration(timestamp));
// and retrieving the hour, minute, second, and subsecond values from it
// but it did not scale/modulo the components for negative timestamps
// correctly -- it simply did an abs(timestamp) as documented here:
// https://en.cppreference.com/w/cpp/chrono/hh_mm_ss/hh_mm_ss

The chrono classes are being used wherever possible:

auto const ymd = // convenient chrono class handles the leap year calculations for us
cuda::std::chrono::year_month_day(
cuda::std::chrono::year{timeparts.year},
cuda::std::chrono::month{static_cast<uint32_t>(timeparts.month)},
cuda::std::chrono::day{static_cast<uint32_t>(timeparts.day)});
auto const days = cuda::std::chrono::sys_days(ymd).time_since_epoch().count();

return cuda::std::chrono::year_month_day(cuda::std::chrono::year{year},
cuda::std::chrono::month{month},
cuda::std::chrono::day{day})
.ok();

and have been helpful in handling tricky calculations like:

I don't believe there is anything left in this file that can benefit from the chrono classes.
Therefore, I'd like to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request libcudf Affects libcudf (C++/CUDA) code.
Projects
None yet
Development

No branches or pull requests

2 participants