4 ms·
Too many modules: datetime, time, calendar, dateutil, pytz and more Yes. [1] Back in 2012, I filed a Python bug report that "datetime" has a formatter for ISO
by Animats 6y ago
Too many modules: datetime, time, calendar, dateutil, pytz and more
Yes. [1] Back in 2012, I filed a Python bug report that "datetime" has a formatter for ISO 8601 format strings, but no parser. I'd found four parsers, all with serious bugs.
After six years of discussion, it was fixed.[1]
[1] https://bugs.python.org/issue15873 https://bugs.python.org/issue15873
- xapata 6y agoIf four popular parsers all had serious bugs, 6 years seems not too shabby.
- mixmastamyk 6y agoNeat, I had an impact on that. I found your bug after also needing a matching parser and went on the mailing list to ask for it. Had to come back twice more to complain and get people to focus and get the ball rolling. Perfect is the enemy of the good in a nutshell. (8601 is a huge spec, and we only needed a matching parser to start with. It is now free to grow.)
- Animats 6y agoThis subject does seems to attract bikeshedding.
- mixmastamyk 6y agoIIRC it was, what about weeks? Time periods? Offsets vs zones? (Other esoteric features.) "Just have it parse .isoformat() and ship it!!"
- 1wd 6y agoIt still does not parse all ISO 8601 format strings: "ISO 8601, RFC 3339 and datetime.isoformat() are three slightly different and in some senses incompatible datetime serialization formats" https://bugs.python.org/issue35829 https://bugs.python.org/issue35829 For example it rejects typical strings produced by Javascript using Z instead of +00:00 as the timezone suffix.
- MaxBarraclough 6y agoIs there a bug filed for this?
- uranusjr 6y agoIIRC this was considered out of scope. fromisoformat is defined as the functional inverse of toisoformat, and since the latter never emits Zulu, the former does not parse it. The only “reasonable” fix would be to rename those functions to something else, but every report on this I’ve seen stop right here. Core maintainers are not really interested in changing this until someone makes them, and nobody really demanded the rename.
- ForHackernews 6y agoThe actual specification ISO 8601 costs like 300 bucks[0] to get a copy of, so hardly any developers implementing time libraries have ever read it. The reason ISO 8601 handling is broken is because all these libraries are implementing against a wikipedia summary of a spec. It's a strong argument for free, open standards. [0] https://shop.bsigroup.com/ProductDetail/?pid=000000000030078726 https://shop.bsigroup.com/ProductDetail/?pid=000000000030078...