News for hackers. Stuff that matters.
Re:Pendulum – Python datetimes made easy by josefdlange on Tuesday August 16, 2016 @10:20PM (#12302082)
What benefits does this have over [Delorean](http://delorean.readthedocs.io/en/latest/)?

The README for Pendulum seems to show me one feature Delorean doesn't explicitly have -- `is_weekend()` -- otherwise these libraries are conceptually very similar.

I do agree that this (and Delorean) is a usability improvement over `datetime` and perhaps even Arrow (though I'm not tremendously familiar with Arrow).

Re:Pendulum – Python datetimes made easy by sdispater on Tuesday August 16, 2016 @11:26PM (#12302335)
Mainly, its API which tries to be as close as possible as the one provided by the standard datetime library while providing a bunch of helpful methods.

Also, Pendulum is not just about datetimes but also provides both the Interval class and Period class which are improvements over the native timedelta class.

And finally, it handles properly time shifting around DST transition times and normalization of datetimes when creating them which neither Delorean nor Arrow do well.

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.
Re:Pendulum – Python datetimes made easy by dvl on Wednesday August 17, 2016 @11:09AM (#12305264)
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.
Re:Pendulum – Python datetimes made easy by ak217 on Sunday August 21, 2016 @06:04PM (#12332923)
They both import all three under the hood.
Re:Pendulum – Python datetimes made easy by antar on Tuesday August 16, 2016 @10:56PM (#12302219)
arrow.get(value).humanize()

How can I do this with datetime+dateutil+pytz?

Re:Pendulum – Python datetimes made easy by ak217 on Tuesday August 16, 2016 @11:39PM (#12302373)
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.