Skip to content

Commit 8f32f3c

Browse files
NoahStappblink1073
andauthored
PYTHON-4831 - Remove pytz from examples (#1904)
Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
1 parent d21a8dd commit 8f32f3c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

doc/examples/datetimes.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ those datetimes to UTC automatically:
7070

7171
.. doctest::
7272

73-
>>> import pytz
74-
>>> pacific = pytz.timezone("US/Pacific")
75-
>>> aware_datetime = pacific.localize(datetime.datetime(2002, 10, 27, 6, 0, 0))
73+
>>> from zoneinfo import ZoneInfo
74+
>>> from datetime import datetime
75+
>>> aware_datetime = datetime(2002, 10, 27, 6, 0, 0, tzinfo=ZoneInfo("US/Pacific"))
7676
>>> result = db.times.insert_one({"date": aware_datetime})
7777
>>> db.times.find_one()["date"]
7878
datetime.datetime(2002, 10, 27, 14, 0)
@@ -97,7 +97,7 @@ out of MongoDB in US/Pacific time:
9797
datetime.datetime(2002, 10, 27, 14, 0)
9898
>>> aware_times = db.times.with_options(codec_options=CodecOptions(
9999
... tz_aware=True,
100-
... tzinfo=pytz.timezone('US/Pacific')))
100+
... tzinfo=ZoneInfo("US/Pacific")))
101101
>>> result = aware_times.find_one()['date']
102102
datetime.datetime(2002, 10, 27, 6, 0, # doctest: +NORMALIZE_WHITESPACE
103103
tzinfo=<DstTzInfo 'US/Pacific' PST-1 day, 16:00:00 STD>)

0 commit comments

Comments
 (0)