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

Closes issue bpo-5288: Allow tzinfo objects with sub-minute offsets. #2896

Merged
merged 6 commits into from
Jul 31, 2017

Conversation

abalkin
Copy link
Member

@abalkin abalkin commented Jul 26, 2017

@csabella
Copy link
Contributor

The comments above the functions and the documentation still mention a 'whole number of minutes'. Do these need to be modified?

@abalkin
Copy link
Member Author

abalkin commented Jul 27, 2017

@csabella - yes the comments and the documentation should be fixed. Can you point me to the specific instances?

@csabella
Copy link
Contributor

Thanks @abalkin.

I'm not able to leave a comment in the code on lines that haven't been modified, but it's line 244 in datetime.py, right above the def _check_utc_offset.

In the datetime.rst, it's probably easiest to search on the word whole. There are several occurrences and I'm not sure which ones are applicable, but I think maybe all of them?

@abalkin
Copy link
Member Author

abalkin commented Jul 27, 2017

@csabella - please see 97d8d5b.

@csabella
Copy link
Contributor

Thank you. Looks good. You even caught the ones in the C code that I had missed. Can you just recheck the tzinfo.utcoffset(dt) paragraph on datetime.rst? It still mentions the whole number of minutes and I'm not sure if you intended to leave that in or not.

@abalkin abalkin requested a review from vstinner July 27, 2017 21:35
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, LGTM, just minor nits.

But I have a question for %z: does it support microseconds or not? According to the doc, it doesn't: so please clarify the ".. versionchanged:: 3.7" note.

Lib/datetime.py Outdated
seconds = rest.seconds
microseconds = rest.microseconds
if microseconds:
return 'UTC{}{:02d}:{:02d}:{:02d}.{:06d}'.format(sign,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may use f-string here ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

minutes. For example, if :meth:`utcoffset` returns
``timedelta(hours=-3, minutes=-30)``, ``%z`` is replaced with the string
``'-0330'``.

.. versionchanged:: 3.7
The UTC offset is not restricted to a whole number of minutes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest to be more explicit: mention that optional support for seconds was added, since microseconds are not supported here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, microseconds are supported here. Will larigy.

seconds = GET_TD_SECONDS(offset);
Py_DECREF(offset);
minutes = divmod(seconds, 60, &seconds);
hours = divmod(minutes, 60, &minutes);
/* XXX ignore sub-minute data, currently not allowed. */
assert(seconds == 0);
if (microseconds != 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add { ... } of the if blocks, it's now required by the PEP 7 for new C code.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do.

@vstinner
Copy link
Member

The Travis docs job failed:

/home/travis/build/python/cpython/Doc/library/datetime.rst:1658:Block quote ends without a blank line; unexpected unindent.

@abalkin abalkin merged commit 018d353 into python:master Jul 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants