-
Notifications
You must be signed in to change notification settings - Fork 4.1k
ARROW-5125: [Python] Round-trip extreme dates on windows #5306
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
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e99b04b
ARROW-5125: [Python] Round-trip extreme dates on windows
emkornfield ffd6dc6
update callsites to use timestamp to seconds
emkornfield 0f61786
consistent multiply
emkornfield b5bd763
fix ms->s
emkornfield 977068d
fix other callsite for PyDate_to_ms
emkornfield b8c78eb
add missing else
emkornfield a2b5a8f
Truncate intraday milliseconds from datetime.datetime values when con…
wesm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -272,9 +272,6 @@ static inline int64_t PyDate_to_days(PyDateTime_Date* pydate) { | |
|
|
||
| static inline int64_t PyDate_to_ms(PyDateTime_Date* pydate) { | ||
| int64_t total_seconds = 0; | ||
| total_seconds += PyDateTime_DATE_GET_SECOND(pydate); | ||
|
||
| total_seconds += PyDateTime_DATE_GET_MINUTE(pydate) * 60; | ||
| total_seconds += PyDateTime_DATE_GET_HOUR(pydate) * 3600; | ||
| int64_t days = | ||
| get_days_from_date(PyDateTime_GET_YEAR(pydate), PyDateTime_GET_MONTH(pydate), | ||
| PyDateTime_GET_DAY(pydate)); | ||
|
|
@@ -283,17 +280,23 @@ static inline int64_t PyDate_to_ms(PyDateTime_Date* pydate) { | |
| } | ||
|
|
||
| static inline int64_t PyDateTime_to_s(PyDateTime_DateTime* pydatetime) { | ||
| return PyDate_to_ms(reinterpret_cast<PyDateTime_Date*>(pydatetime)) / 1000LL; | ||
| int64_t total_seconds = 0; | ||
| total_seconds += PyDateTime_DATE_GET_SECOND(pydatetime); | ||
| total_seconds += PyDateTime_DATE_GET_MINUTE(pydatetime) * 60; | ||
| total_seconds += PyDateTime_DATE_GET_HOUR(pydatetime) * 3600; | ||
|
|
||
| return total_seconds + | ||
| (PyDate_to_ms(reinterpret_cast<PyDateTime_Date*>(pydatetime)) / 1000LL); | ||
| } | ||
|
|
||
| static inline int64_t PyDateTime_to_ms(PyDateTime_DateTime* pydatetime) { | ||
| int64_t date_ms = PyDate_to_ms(reinterpret_cast<PyDateTime_Date*>(pydatetime)); | ||
| int64_t date_ms = PyDateTime_to_s(pydatetime) * 1000; | ||
| int ms = PyDateTime_DATE_GET_MICROSECOND(pydatetime) / 1000; | ||
| return date_ms + ms; | ||
| } | ||
|
|
||
| static inline int64_t PyDateTime_to_us(PyDateTime_DateTime* pydatetime) { | ||
| int64_t ms = PyDate_to_ms(reinterpret_cast<PyDateTime_Date*>(pydatetime)); | ||
| int64_t ms = PyDateTime_to_s(pydatetime) * 1000; | ||
| int us = PyDateTime_DATE_GET_MICROSECOND(pydatetime); | ||
| return ms * 1000 + us; | ||
| } | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might not be necessary, if we never expect a datetime object here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact I think this is wrong (we always want truncation, but I'll let the reviewer confirm).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's probably OK, but we should check whether the milliseconds are 0. I'll pull it down and take a quick look