Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #75407
| From | Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> |
|---|---|
| Subject | converting ISO8601 date and time string representations to datetime |
| Date | 2014-07-31 11:11 +0200 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12461.1406797909.18130.python-list@python.org> (permalink) |
Hi, I'm trying to convert ISO8601-compliant strings representing dates or dates and times into datetime.datetime objects. I tried using the strptime method, but the problem here is that I can only specify one format argument, which can be used to parse either a full date/time string or just a date string, but not both. While I could just try parsing with one format, then catch the ValueError in case it fails and try another format, it feels like there should be a more elegant way to do this. I do know about the dateutil package, but I'd prefer to stick to the stdlib for this. Any suggestions ? Wolfgang
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
converting ISO8601 date and time string representations to datetime Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-07-31 11:11 +0200
Re: converting ISO8601 date and time string representations to datetime Roy Smith <roy@panix.com> - 2014-07-31 07:52 -0400
Re: converting ISO8601 date and time string representations to datetime Skip Montanaro <skip@pobox.com> - 2014-07-31 07:59 -0500
Re: converting ISO8601 date and time string representations to datetime Roy Smith <roy@panix.com> - 2014-07-31 09:13 -0400
Re: converting ISO8601 date and time string representations to datetime Wolfgang Maier <wolfgang.maier@biologie.uni-freiburg.de> - 2014-07-31 15:29 +0200
csiph-web