
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2019-02-15 14:28 byp-ganssle, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11888 | merged | p-ganssle,2019-02-16 00:08 | |
| Messages (7) | |||
|---|---|---|---|
| msg335616 -(view) | Author: Paul Ganssle (p-ganssle)*![]() | Date: 2019-02-15 14:28 | |
Datetime has many methods that "serializes" an instance to some other format - toordinal, timestamp, isoformat, etc. Most methods that "serialize" a datetime have a corresponding method that "deserializes" that method, or another way to reverse the operation:- strftime / strptime- timestamp / fromtimestamp- isoformat / fromisoformat- toordinal / fromordinal- timetuple / datetime(*thetuple[0:6])However, as I found out when implementing `dateutil.parser.isoparse`, there is no simple way to invert `isocalendar()`.I have an implementation as part of dateutil.parser.isoparse:https://github.com/dateutil/dateutil/blob/master/dateutil/parser/isoparser.py#L297If there are no objections, I'd like to add an implementation in CPython itself. Thinking the name should be `fromisocalendar`. | |||
| msg335617 -(view) | Author: Stéphane Wirtel (matrixise)*![]() | Date: 2019-02-15 14:31 | |
+1 | |||
| msg335641 -(view) | Author: Emmanuel Arias (eamanu)* | Date: 2019-02-15 19:19 | |
+1 | |||
| msg335661 -(view) | Author: Paul Ganssle (p-ganssle)*![]() | Date: 2019-02-16 00:15 | |
I have a first-pass PR, a few questions to address:1. Should it take three arguments or a single 3-tuple? (I've gone with 3 arguments)2. Since all three arguments are required, should we make them positional-only?3. Should we allow time components in the `datetime` flavor of this? If so, I think we would also want datetime.isocalendar() to return a longer tuple, which would be backwards incompatible.4. Should we add a `tz` argument in the datetime flavor?I think for questions 3 and 4 the answer is no, modelling after .toordinal/.fromordinal. | |||
| msg335783 -(view) | Author: Paul Ganssle (p-ganssle)*![]() | Date: 2019-02-17 18:07 | |
The attached PR is more or less fully ready, I think the correct answers to 1, 3 and 4 are that we should go with 3 separate arguments and we should not allow either time components or tz components, at least in this version.In the future, I don't think it will be backwards incompatible to add in these features if they are desired (though I imagine they won't be terribly in demand, and it's pretty easy to work around).The only real remaining question is number 2. Right now I am allowing keyword arguments, but the only real value I see in doing that is thatPEP 570 (positional-only parameters) is not done yet and it's kind of annoying to implement "positional only parameters" in the pure Python version. If anyone feels strongly about this, let me know, otherwise I'll switch the implementation over to positional-only parameters. | |||
| msg341079 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2019-04-29 13:22 | |
New changeset88c093705615c50c47fdd9ab976803f73de7e308 by Victor Stinner (Paul Ganssle) in branch 'master':bpo-36004: Add date.fromisocalendar (GH-11888)https://github.com/python/cpython/commit/88c093705615c50c47fdd9ab976803f73de7e308 | |||
| msg341080 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2019-04-29 13:31 | |
Thanks Paul, nice enhancement! | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:11 | admin | set | github: 80185 |
| 2019-04-29 13:31:05 | vstinner | set | status: open -> closed resolution: fixed messages: +msg341080 stage: patch review -> resolved |
| 2019-04-29 13:22:06 | vstinner | set | nosy: +vstinner messages: +msg341079 |
| 2019-02-17 18:07:49 | p-ganssle | set | messages: +msg335783 |
| 2019-02-16 00:15:42 | p-ganssle | set | messages: +msg335661 |
| 2019-02-16 00:08:41 | p-ganssle | set | keywords: +patch stage: patch review pull_requests: +pull_request11918 |
| 2019-02-15 19:19:43 | eamanu | set | nosy: +eamanu messages: +msg335641 |
| 2019-02-15 14:31:05 | matrixise | set | nosy: +matrixise messages: +msg335617 |
| 2019-02-15 14:28:36 | p-ganssle | create | |