-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-30155: Add macros to get tzinfo from datetime instances #21633
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Add PyDateTime_DATE_GET_TZINFO() and PyDateTime_TIME_GET_TZINFO() macros.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Add :c:func:`PyDateTime_DATE_GET_TZINFO` and | ||
:c:func:`PyDateTime_TIME_GET_TZINFO` macros for accessing the ``tzinfo`` | ||
attributes of :class:`datetime.datetime` and :class:`datetime.time` objects. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -484,9 +484,7 @@ zoneinfo_tzname(PyObject *self, PyObject *dt) | |
return tti->tzname; | ||
} | ||
|
||
#define HASTZINFO(p) (((_PyDateTime_BaseTZInfo *)(p))->hastzinfo) | ||
#define GET_DT_TZINFO(p) \ | ||
(HASTZINFO(p) ? ((PyDateTime_DateTime *)(p))->tzinfo : Py_None) | ||
#define GET_DT_TZINFO PyDateTime_DATE_GET_TZINFO | ||
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. Alternatively we can replace all the instances of #ifdef PyDateTime_DATE_GET_TZINFO
#define GET_DT_TZINFO PyDateTime_DATE_GET_TZINFO
#else
#define HASTZINFO ...
or I'll do this: #ifndef PyDateTime_DATE_GET_TZINFO
#define _PyDateTime_HAS_TZINFO ...
#define PyDateTime_DATE_GET_TZINFO (_PyDateTime_HAS_TZINFO(p) ? ...
Then the rest of the file will be the same. I was originally liking the first one, but upon further reflection, I like the second one. What do you think? (It's also OK to say that you like the second one more but you want to keep it out of scope of this PR). 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. I like the second one more, but I think it is out of scope for this PR. :) |
||
|
||
static PyObject * | ||
zoneinfo_fromutc(PyObject *obj_self, PyObject *dt) | ||
|
Uh oh!
There was an error while loading. Please reload this page.