Hacker News new | ask | show | jobs
by niftich 3439 days ago
Thanks for this. Pendulum is, in my opinion, the most palatable datetime lib for Python. Things I'm looking for are:

- a domain model that doesn't conflate unrelated concepts: a human-perceived 'calendar date' is not the same as a timestamp. The two are not inherently comparable, and should be modelled as distinct classes [1].

- an API design that tries to adhere to the language's typical conventions, and cater to the mental model and needs of the language's users.

Unfortunately, Python has had a warped understanding of datetime from the very beginning, so these two are always at odds. But Pendulum does a better job than most, by normalizing stuff like .tomorrow() to midnight in the given timezone, by having sane defaults that tend to avoid common pitfalls, and by resisting Arrow's fast and loose way of dealing with datetime.

Delorean, a worthy alternative, makes slightly different design decisions, (e.g. about extending the datetime object, and how to treat naive datetimes) and I think a detailed comparison would benefit the community.

[1] https://news.ycombinator.com/item?id=12364805

1 comments

Thanks for the kind words :-) I really appreciate it and I'm glad you find it useful.