@@ -253,12 +253,30 @@ can be changed to this::
253253 client.options.pool_options.min_pool_size
254254 client.options.pool_options.max_idle_time_seconds
255255
256+ .. _tz_aware_default_change :
257+
256258``tz_aware `` defaults to ``False ``
257259..................................
258260
259- ``tz_aware ``, an argument for :class: `~bson.json_util.JSONOptions `,
260- now defaults to ``False `` instead of ``True ``. ``json_util.loads `` now
261- decodes datetime as naive by default.
261+ The ``tz_aware `` argument to :class: `~bson.json_util.JSONOptions `
262+ now defaults to ``False `` instead of ``True ``. :meth: `bson.json_util.loads `
263+ now decodes datetime as naive by default::
264+
265+ >>> from bson import json_util
266+ >>> s = '{"dt": {"$date": "2022-05-09T17:54:00Z"}}'
267+ >>> json_util.loads(s)
268+ {'dt': datetime.datetime(2022, 5, 9, 17, 54)}
269+
270+ To retain the PyMongo 3 behavior set ``tz_aware=True ``, for example::
271+
272+ >>> from bson import json_util
273+ >>> opts = json_util.JSONOptions(tz_aware=True)
274+ >>> s = '{"dt": {"$date": "2022-05-09T17:54:00Z"}}'
275+ >>> json_util.loads(s, json_options=opts)
276+ {'dt': datetime.datetime(2022, 5, 9, 17, 54, tzinfo=<bson.tz_util.FixedOffset object at 0x7fd1ebc1add0>)}
277+
278+ This change was made to match the default behavior of
279+ :class: `~bson.codec_options.CodecOptions ` and :class: `bson.decode `.
262280
263281MongoClient cannot execute operations after ``close() ``
264282.......................................................
0 commit comments