@@ -70,9 +70,9 @@ those datetimes to UTC automatically:
70
70
71
71
.. doctest ::
72
72
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 " ))
76
76
>>> result = db.times.insert_one({" date" : aware_datetime})
77
77
>>> db.times.find_one()[" date" ]
78
78
datetime.datetime(2002, 10, 27, 14, 0)
@@ -97,7 +97,7 @@ out of MongoDB in US/Pacific time:
97
97
datetime.datetime(2002, 10, 27, 14, 0)
98
98
>>> aware_times = db.times.with_options(codec_options = CodecOptions(
99
99
... tz_aware= True ,
100
- ... tzinfo= pytz.timezone( ' US/Pacific' )))
100
+ ... tzinfo= ZoneInfo( " US/Pacific" )))
101
101
>>> result = aware_times.find_one()[' date' ]
102
102
datetime.datetime(2002, 10, 27, 6, 0, # doctest: +NORMALIZE_WHITESPACE
103
103
tzinfo=<DstTzInfo 'US/Pacific' PST-1 day, 16:00:00 STD>)
0 commit comments