Message363123
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)
``` |
|
Date |
User |
Action |
Args |
2020-03-02 06:17:00 | nickzoic | set | recipients:
+ nickzoic, gregory.p.smith, belopolsky, polymorphm, Sriram Rajagopalan, xtreak |
2020-03-02 06:17:00 | nickzoic | set | messageid: <1583129820.29.0.858565169634.issue26460@roundup.psfhosted.org> |
2020-03-02 06:17:00 | nickzoic | link | issue26460 messages |
2020-03-02 06:17:00 | nickzoic | create | |
|