Pendulum – Python datetimes made easy
github.com
Pendulum – Python datetimes made easy
1–10 of 76 posts
Re: Pendulum – Python datetimes made easy
#2It is heavily inspired by [Carbon](http://carbon.nesbot.com) for PHP.
Basically, the Pendulum class is a replacement for the native datetime one with some useful and intuitive methods, the Interval class is intended to be a better time delta class and, finally, the Period class is a datetime-aware timedelta.
Timezones are also easier to deal with: Pendulum will automatically normalize your datetime to handle DST transitions for you.
import pendulum
pendulum.create(2013, 3, 31, 2, 30, 0, 0, 'Europe/Paris’)
# 2:30 for the 31th of March 2013 does not exist
# so pendulum will return the actual time which is 3:30+02:00
'2013-03-31T03:30:00+02:00’
dt = pendulum.create(2013, 3, 31, 1, 59, 59, 999999, 'Europe/Paris’)
'2013-03-31T01:59:59.999999+01:00’
dt = dt.add(microseconds=1)
'2013-03-31T03:00:00+02:00’
dt.subtract(microseconds=1)
'2013-03-31T01:59:59.999998+01:00’
To those wondering: yes I know [Arrow](http://crsmithdev.com/arrow/) exists but its flaws and strange API (you can throw almost anything at get() and it will do its best to determine what you wanted, for instance) motivated me to start this project. You can check why I think Arrow is flawed here: https://pendulum.eustace.io/faq/#why-not-arrowLink to the official documentation: https://pendulum.eustace.io/docs/
Link to the github project: https://github.com/sdispater/pendulum
Re: Pendulum – Python datetimes made easy
#3On the otherhand if you've e.g. Ruby/Rails datetime handling than you get used to reasonable things working ( such as Time.now + 1.day ) that Arrow doesn't handle well. As a matter of fact Arrow got rid of DT deltas and seemingly made the situation worse.
I've only looked at the examples in the docs; but to be serious, Python should just scrap their DT/time/calendar libs and copy Ruby verbatim. This NIH thing needs to stop..
Re: Pendulum – Python datetimes made easy
#4Pendulum is a new library for Python to ease datetimes, timedeltas and timezones manipulation. It is heavily inspired by [Carbon]( http://carbon.nesbot.com ) for PHP. Basically, the Pendulum class is a replacement for the native datetime one with some useful and intuitive methods, the Interval class is intended to be a better time delta class and, finally, the Period class is a datetime-aware timedelta. Timezones are…
Re: Pendulum – Python datetimes made easy
#5Python stdlib datetime/time/calendar libs are junk. That one constantly has to read obscure function signatures in the docs to do rather obvious things is just awful. On the otherhand if you've e.g. Ruby/Rails datetime handling than you get used to reasonable things working ( such as Time.now + 1.day ) that Arrow doesn't handle well. As a matter of fact Arrow got rid of DT deltas and seemingly made the situation wors…
I don't see anything unreasonable about Pendulum's interface. Let's let Python be Python and Ruby be Ruby.
Re: Pendulum – Python datetimes made easy
#6Python stdlib datetime/time/calendar libs are junk. That one constantly has to read obscure function signatures in the docs to do rather obvious things is just awful. On the otherhand if you've e.g. Ruby/Rails datetime handling than you get used to reasonable things working ( such as Time.now + 1.day ) that Arrow doesn't handle well. As a matter of fact Arrow got rid of DT deltas and seemingly made the situation wors…
1.day? I confess to not being a Rubyist, but does that require monkeypatching the base int class? I don't see anything unreasonable about Pendulum's interface. Let's let Python be Python and Ruby be Ruby.
Re: Pendulum – Python datetimes made easy
#7The 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
#8Python stdlib datetime/time/calendar libs are junk. That one constantly has to read obscure function signatures in the docs to do rather obvious things is just awful. On the otherhand if you've e.g. Ruby/Rails datetime handling than you get used to reasonable things working ( such as Time.now + 1.day ) that Arrow doesn't handle well. As a matter of fact Arrow got rid of DT deltas and seemingly made the situation wors…
1.day? I confess to not being a Rubyist, but does that require monkeypatching the base int class? I don't see anything unreasonable about Pendulum's interface. Let's let Python be Python and Ruby be Ruby.
Re: Pendulum – Python datetimes made easy
#9Earlier quoted context omitted.
1.day? I confess to not being a Rubyist, but does that require monkeypatching the base int class? I don't see anything unreasonable about Pendulum's interface. Let's let Python be Python and Ruby be Ruby.
No, don't think so. I think this is a native syntax construct in Ruby.
Re: Pendulum – Python datetimes made easy
#10What 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).