-
-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Add tzinfo= argument to datetime.combine #71848
Comments
Add an optional tzinfo argument to datetime.combine() so that datetime.combine(d, t, info) returns the same object as datetime.combine(d, t).replace(tzinfo=info) but without creating an intermediate naive instance. Guido's LGTM: https://mail.python.org/pipermail/datetime-sig/2016-July/000993.html |
The second patch includes documentation changes and addresses review commments. |
From review comments: Lib/datetime.py:1482: def combine(cls, date, time, tzinfo=True):
This is the same default as used in the .replace() methods. Arguably, a proper sentinel value would be a better choice, but I think True delivers better performance. In any case, this is not something I would change without consulting with the PyPy folks. See <http://bugs.python.org/review/27661/diff/18026/Lib/datetime.py#newcode1482\>. |
From review comments: Lib/datetime.py:1482: def combine(cls, date, time, tzinfo=True):
tzinfo is not kw-only in the other constructors and I don't think it should be here. Unlike "fold", tzinfo value is usually recognizable at the call site. It is either called something like "tzinfo", "tz" or "New_York" or is a call such as 'tz.get('US/Eastern'). I would always prefer datetime.combine(d, t, tzinfo) to datetime.combine(d, t, tzinfo=tzinfo). datetime.combine(d, t, New_York) vs. datetime.combine(d, t, tzinfo=New_York) is a closer call, but still the first form is readable enough. See <http://bugs.python.org/review/27661/diff/18026/Lib/datetime.py#newcode1482\>. |
New changeset adce94a718e3 by Alexander Belopolsky in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: