Skip to content

Commit 488c588

Browse files
committed
Updates README
1 parent c637d69 commit 488c588

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

README.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,56 @@ Python datetimes made easy.
3434
>>> delta.in_words(locale='en')
3535
'6 days 23 hours 58 minutes'
3636
37+
38+
Why Pendulum?
39+
=============
40+
41+
Unlike other datetime libraries for Python, Pendulum is a drop-in replacement
42+
for the standard ``datetime`` class (it inherits from it), so, basically, you can replace all your ``datetime``
43+
instances by ``Pendulum`` instances in you code (exceptions exist for libraries that check
44+
the type of the objects by using the ``type`` function like ``sqlite3`` or ``PyMySQL`` for instance).
45+
46+
It also removes the notion of naive datetimes: each ``Pendulum`` instance is timezone-aware
47+
and by default in ``UTC`` for ease of use.
48+
49+
Pendulum also improves the standard ``timedelta`` class by providing more intuitive methods and properties.
50+
See the `Documentation <http://pendulum.eustace.io/docs/#interval>`_ for more information.
51+
52+
53+
Why not Arrow?
54+
==============
55+
56+
Arrow is the most popular datetime library for Python right now, however its behavior
57+
and API can be erratic and unpredictable. The ``get()`` method can receive pretty much anything
58+
and it will try its best to return something while silently failing to handle some cases:
59+
60+
.. code-block:: python
61+
62+
arrow.get('2016-1-17')
63+
#<Arrow [2016-01-01T00:00:00+00:00]>
64+
65+
pendulum.parse('2016-1-17')
66+
#<Pendulum [2016-01-17T00:00:00+00:00]>
67+
68+
# Parsing of a date with wrong day
69+
arrow.get('2015-06-31')
70+
#<Arrow [2015-06-01T00:00:00+00:00]>
71+
72+
pendulum.parse('2016-06-31')
73+
# ValueError: day is out of range for month
74+
75+
# fromtimestamp with timezone displays wrong offset
76+
arrow.Arrow.fromtimestamp(0, pytz.timezone('Europe/Paris'))
77+
#<Arrow [1970-01-01T01:00:00+00:09]>
78+
79+
pendulum.from_timestamp(0, pytz.timezone('Europe/Paris'))
80+
# fromtimestamp() is also possible
81+
#<Pendulum [1970-01-01T01:00:00+01:00]>
82+
83+
Those are a few examples showing that Arrow cannot always be trusted to have a consistent
84+
behavior with the data you are passing to it.
85+
86+
3787
Resources
3888
=========
3989

0 commit comments

Comments
 (0)