Re:Pendulum – Python datetimes made easy
by ak217 on Tuesday August 16, 2016 @10:50PM
(#12302199)
So far I haven't seen either of these libraries do substantially better than datetime+dateutil+pytz at anything they claim to be good at.
[ Parent
| on HN ]
I'm happy to not have to import 3 libraries anymore (2 that aren't part of standard library) to see if one date is greater than another or to add few days to a date.
They both import all three under the hood.
arrow.get(value).humanize()
How can I do this with datetime+dateutil+pytz?
I was talking about delorean and pendulum (I think josefdlange edited his comment). I agree that arrow's multi-locale natural language renderer does add a lot of value. (Although I'd argue it should be unbundled into its own module, instead of Arrow trying to replace a ton of datetime/dateutil functionality.)
Re:Pendulum – Python datetimes made easy
by masklinn on Wednesday August 17, 2016 @08:16AM
(#12304070)
> I agree that arrow's multi-locale natural language renderer does add a lot of value. Although I'd argue it should be unbundled into its own module
http://babel.pocoo.org/en/latest/api/dates.html
humanize is apparently a human-readable directioned delta, so that'd be format_timedelta(delta, add_direction=True)
>>> print format_timedelta(ref - datetime.now(), add_direction=True)
1 hour ago
>>> print format_timedelta(ref - datetime.now(), add_direction=True, locale='zh')
1小时前
>>> print format_timedelta(ref - datetime.now(), add_direction=True, locale='ru')
1 час назад
Re:Pendulum – Python datetimes made easy
by josefdlange on Wednesday August 17, 2016 @11:44AM
(#12305530)
No editing here but that's okay. I only just came back to this conversation now :D
I think Delorean, Pendulum, Arrow, etc, aim to make dealing with dates more understandable and less painful. It's perfectly possible to fully grasp all the technicalities of pytz/dateutil/datetime -- and I recommend that anybody who has to deal with dates and times in Python do so -- but if you'd rather not think about it all and are okay with deferring some control to the opinions of one of these libraries, that's when you probably pull them off the shelf instead of the aforementioned trio.