3 ms·
I'm competent with strptime(), but this looks really nice: # Automatically parse datetime strings and generate naive datetimes. >>> scraped = '2016-12-
by japhyr 10y ago
I'm competent with strptime(), but this looks really nice:
# Automatically parse datetime strings and generate naive datetimes.
>>> scraped = '2016-12-16 18:23:45.423992+00:00'
>>> maya.parse(scraped).datetime(to_timezone='US/Eastern', naive=True)
datetime.datetime(2016, 12, 16, 13, 23, 45, 423992)
I'm happy not to have to write formatting arguments to strptime() anymore. Do the other datetime libraries have similar parsing functions?
- detaro 10y agoMaya actually uses the dateutil.parser.parse function from dateutils under the hood, which as far as I remember is the most comprehensive such function among the typical python datetime libs.
- japhyr 10y agoWow, I've been using datetime for years, without ever noticing the dateutil library. I'll use this from now on.