You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/basics.rst
+24
Original file line number
Diff line number
Diff line change
@@ -296,4 +296,28 @@ Example of using group_by_sort_key
296
296
'old_value': 'Blue'}}}
297
297
298
298
299
+
.. _default_timezone_label:
300
+
301
+
Default Time Zone
302
+
-----------------
303
+
304
+
default_timezone defines the default timezone. If a datetime is timezone naive, which means it doesn't have a timezone, we assume the datetime is in this timezone. Also any datetime that has a timezone will be converted to this timezone so the datetimes can be compared properly all in the same timezone. Note that Python's default behavior assumes the default timezone is your local timezone. DeepDiff's default is UTC, not your local time zone.
305
+
306
+
307
+
Note that if we change the default_timezone, the output timezone changes accordingly
308
+
>>> from deepdiff import DeepDiff
309
+
>>> import pytz
310
+
>>> from datetime import date, datetime, time, timezone
:ref:`custom_operators_label` if you are considering whether they are fruits or not. In that case, you can pass a *custom_operators* for the job.
41
41
42
+
default_timezone : datetime.timezone subclasses or pytz datetimes, default = datetime.timezone.utc
43
+
:ref:`default_timezone_label` defines the default timezone. If a datetime is timezone naive, which means it doesn't have a timezone, we assume the datetime is in this timezone. Also any datetime that has a timezone will be converted to this timezone so the datetimes can be compared properly all in the same timezone. Note that Python's default behavior assumes the default timezone is your local timezone. DeepDiff's default is UTC, not your local time zone.
44
+
42
45
encodings: List, default = None
43
46
:ref:`encodings_label` Character encodings to iterate through when we convert bytes into strings. You may want to pass an explicit list of encodings in your objects if you start getting UnicodeDecodeError from DeepHash. Also check out :ref:`ignore_encoding_errors_label` if you can get away with ignoring these errors and don't want to bother with an explicit list of encodings but it will come at the price of slightly less accuracy of the final results. Example: encodings=["utf-8", "latin-1"]
Copy file name to clipboardExpand all lines: docs/faq.rst
+2-1
Original file line number
Diff line number
Diff line change
@@ -154,7 +154,7 @@ Q: Why my datetimes are reported in UTC?
154
154
**Answer**
155
155
156
156
DeepDiff converts all datetimes into UTC. If a datetime is timezone naive, we assume it is in UTC too.
157
-
That is different than what Python does. Python assumes your timezone naive datetime is in your local timezone.
157
+
That is different than what Python does. Python assumes your timezone naive datetime is in your local timezone. However, you can override it to any other time zone such as your :ref:`default_timezone_label`.
158
158
159
159
>>> from deepdiff import DeepDiff
160
160
>>> from datetime import datetime, timezone
@@ -171,6 +171,7 @@ That is different than what Python does. Python assumes your timezone naive date
171
171
>>> d1 == d3
172
172
False
173
173
174
+
174
175
---------
175
176
176
177
.. admonition:: A message from `Sep <https://github.com/seperman>`__, the creator of DeepDiff
0 commit comments