Skip to content

Commit 9603143

Browse files
authored
Merge pull request #11049 from taldcroft/time-zone-example
Add Time example parsing a timezone-aware string
2 parents 21f2f1a + 9834eeb commit 9603143

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

‎docs/time/index.rst‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1595,6 +1595,23 @@ object.
15951595

15961596
.. EXAMPLE END
15971597
1598+
1599+
Example
1600+
^^^^^^^
1601+
1602+
.. EXAMPLE START: Initializing From a Timezone-aware Date
1603+
1604+
Using the `dateutil <https://dateutil.readthedocs.io/en/stable/index.html>`_ package,
1605+
you can parse times in a wide variety of supported formats to generate a
1606+
`datetime.datetime` object which can then be used to initialize a |Time| object::
1607+
1608+
>>> from dateutil.parser import parse # doctest: +SKIP
1609+
>>> dtime = parse('2020-10-29T08:20:46.950+1100') # doctest: +SKIP
1610+
>>> Time(dtime) # doctest: +SKIP
1611+
<Time object: scale='utc' format='datetime' value=2020-10-28 21:20:46.950000>
1612+
1613+
.. EXAMPLE END
1614+
15981615
Custom String Formats with ``strftime`` and ``strptime``
15991616
--------------------------------------------------------
16001617

0 commit comments

Comments
 (0)