Skip to content

Commit fd3a871

Browse files
committed
Updates documentation
1 parent 532ba53 commit fd3a871

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

docs/_docs/instantiation.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,14 @@ You can also instantiate ``Pendulum`` instances by passing a string to the ``par
140140
print(dt)
141141
'1975-05-21T22:00:00+00:00
142142
143-
The library natively supports the RFC 3339 format, most ISO 8601 formats and some other common formats. If you pass a non-standard or more complicated
144-
string, the library will fallback on the `dateutil <https://dateutil.readthedocs.io>`_ parser.
143+
# You can pass a tz keyword to specify the timezone
144+
dt = pendulum.parse('1975-05-21 22:00:00', tz='Europe/Paris')
145+
print(dt)
146+
'1975-05-21T22:00:00+01:00'
147+
148+
The library natively supports the RFC 3339 format, most ISO 8601 formats and some other common formats.
149+
If you pass a non-standard or more complicated string, the library will fallback on the
150+
`dateutil <https://dateutil.readthedocs.io>`_ parser.
145151

146152
RFC 3339
147153
~~~~~~~~

docs/_docs/period.rst

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,42 @@ instances that generated it, so that it can give access to more methods and prop
3737
3838
# Note that the weeks property
3939
# will change compared to the Interval class
40-
period.weeks = 2 # 832 for the interval
40+
period.weeks
41+
2 # 832 for the interval
4142
4243
# However the days property will still remain the same
4344
# to keep the compatiblity with the timedelta class
4445
period.days
4546
5829
4647
48+
Be aware that a period, just like an interval, is compatible with the ``timedelta`` class regarding
49+
its attributes. However, its custom attributes (like ``remaining_days``) will be aware of any DST
50+
transitions that might have occurred and adjust accordingly. Let's take an example:
51+
52+
.. code-block:: python
53+
54+
import pendulum
55+
56+
start = pendulum.create(2017, 3, 7, tz='America/Toronto')
57+
end = start.add(days=6)
58+
59+
period = end - start
60+
61+
# timedelta properties
62+
period.days
63+
5
64+
period.seconds
65+
82800
66+
67+
# period properties
68+
period.remaining_days
69+
6
70+
period.hours
71+
0
72+
period.remaining_seconds
73+
0
74+
75+
4776
.. warning::
4877

4978
Due to its nature (fixed duration between two datetimes), most arithmetic operations will

0 commit comments

Comments
 (0)