karl <karl+pythonb...@la-grange.net> added the comment:
Also this. >>> import datetime >>> d0 = datetime.datetime.strptime("2024-0-3 00:00:00", "%Y-%W-%w %H:%M:%S") >>> d0.strftime("%Y-%W-%w %H:%M:%S") '2024-01-3 00:00:00' >>> d1 = datetime.datetime.strptime("2024-1-3 00:00:00", "%Y-%W-%w %H:%M:%S") >>> d1.strftime("%Y-%W-%w %H:%M:%S") '2024-01-3 00:00:00' >>> d2301 = datetime.datetime.strptime("2023-0-1 00:00:00", "%Y-%W-%w %H:%M:%S") >>> d2311 = datetime.datetime.strptime("2023-1-1 00:00:00", "%Y-%W-%w %H:%M:%S") >>> d2301 datetime.datetime(2022, 12, 26, 0, 0) >>> d2311 datetime.datetime(2023, 1, 2, 0, 0) >>> d2311.strftime("%Y-%W-%w %H:%M:%S") '2023-01-1 00:00:00' >>> d2301.strftime("%Y-%W-%w %H:%M:%S") '2022-52-1 00:00:00' Week 0 2023 became Week 52 2022 (which is correct but might lead to surprises) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40236> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com