Author nickzoic
Recipients Sriram Rajagopalan, belopolsky, gregory.p.smith, nickzoic, polymorphm, xtreak
Date 2020-03-02.06:17:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1583129820.29.0.858565169634.issue26460@roundup.psfhosted.org>
In-reply-to
Content
I suspect this is going to come up about this time of every leap year :-/

The workaround is prepending "%Y " to the pattern and eg: "2020 " to the date string, but that's not very nice.

Would adding a kwarg "default_year" be an acceptable solution?
I can't think of any other situation other than leap years when this is going to come up.  If both "default_year" and "%Y" are present throw an exception (maybe therefore just call the kwarg "year")

In the weird case where you want to do date maths involving the month as well, you can always use a safe choice like "default_year=2020" and then fix the year up afterwards:

```
    dt = datetime.strptime(date_str, "%b %d", default_year=2020)
    dt = dt.replace(year=2021 if dt.month > 6 else 2022)
```
History
Date User Action Args
2020-03-02 06:17:00nickzoicsetrecipients: + nickzoic, gregory.p.smith, belopolsky, polymorphm, Sriram Rajagopalan, xtreak
2020-03-02 06:17:00nickzoicsetmessageid: <1583129820.29.0.858565169634.issue26460@roundup.psfhosted.org>
2020-03-02 06:17:00nickzoiclinkissue26460 messages
2020-03-02 06:17:00nickzoiccreate