-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Maintain Timezone Awareness with to_json and date_format="iso" #28912
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 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
bfa1dfa
Added test for failing tz roundtrip
WillAyd 3281b80
Vendored np datetime changes
WillAyd 6bb5640
Working tz info
WillAyd ab4688b
Changed test expectation
WillAyd 7caffc0
Handled utcoffset being None
WillAyd 412478f
fixed wrong tests
WillAyd 647aff4
Moved test location
WillAyd a75fa76
black
WillAyd d29497c
Some docstrings
WillAyd 122a8fb
clang-format run
WillAyd 62ac65e
Whatsnew
WillAyd 6bd2aaa
Error handling and formatting fixup
WillAyd cbf45bd
Test fixups
WillAyd 448f690
Fixed MemErr clears
WillAyd 8153eb1
Fixed segfault
WillAyd 7b5f658
Removed modification to vendored code for colon
WillAyd 7558d07
Added benchmarks:
WillAyd 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
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 |
---|---|---|
|
@@ -28,6 +28,24 @@ This file is derived from NumPy 1.7. See NUMPY_LICENSE.txt | |
#include <numpy/ndarraytypes.h> | ||
#include "np_datetime.h" | ||
|
||
char *_datetime_strings[NPY_DATETIME_NUMUNITS] = { | ||
"Y", | ||
"M", | ||
"W", | ||
"<invalid>", | ||
"D", | ||
"h", | ||
"m", | ||
"s", | ||
"ms", | ||
"us", | ||
"ns", | ||
"ps", | ||
"fs", | ||
"as", | ||
"generic" | ||
}; | ||
|
||
#if PY_MAJOR_VERSION >= 3 | ||
#define PyInt_AsLong PyLong_AsLong | ||
#endif // PyInt_AsLong | ||
|
@@ -321,7 +339,7 @@ int cmp_npy_datetimestruct(const npy_datetimestruct *a, | |
* Returns -1 on error, 0 on success, and 1 (with no error set) | ||
* if obj doesn't have the needed date or datetime attributes. | ||
*/ | ||
int convert_pydatetime_to_datetimestruct(PyDateTime_Date *dtobj, | ||
int convert_pydatetime_to_datetimestruct(PyDateTime_DateTime *dtobj, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Types are pretty loosely checked in this module; changed these to a more exact date time for clarity |
||
npy_datetimestruct *out) { | ||
// Assumes that obj is a valid datetime object | ||
PyObject *tmp; | ||
|
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
Oops, something went wrong.
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.
should this specify that it is only fixed-offset timezones that are now supported? any other names e.g. pd.to_json to mention?
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 actually don't know what fixed versus (assumedly) non-fixed offsets are - can you clarify?
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.
"UTC-8" is a fixed offset. "US/Pacific" (or colloquially-but-inaccurately "PST/PDT") is not a fixed offset.
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.
So I don't think that distinction matters when writing then (?). At least in tests the construction goes something like
pd.date_range(..., tz="US/Eastern")
and it writes out in ISO formatThat may be a problem when reading. There needs to be a follow up on the reading side to support this as this now does the following when using "+0000" instead of "Z" as the time zone designator
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.
Ah never mind...I get what you are saying now. I guess the ISO format is ambiguous as to what timezone it is, so sure fixed only. Can update that on next iteration
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 guess if youve specified date_format="iso" then the user knows what they're getting into. its just annoying that we dont have a nice way to round-trip read/write non-fixed-offset timezones