File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ """
2
+ The `datetime` class is one of the core classes we encounter when tracking
3
+ events at a given date and time. By default, creating an instance with
4
+ `datetime.now` means that an offset-naive datetime object is produced in
5
+ the host's local timezone.
6
+
7
+ An offset-naive `datetime` object is useful for scripts that are run on a
8
+ personal device. Once we use `datetime` objects for web applications that
9
+ are deployed globally, it's important to know which offset `datetime`
10
+ objects are aligned to before processing them.
11
+
12
+ One approach that backend developers use is to store time fields with
13
+ offsets aligned with the UTC (Coordinated Universal Time) timezone. As a
14
+ result, time fields can be easily displayed in any timezone.
15
+
16
+ In this module, we will show the difference between offset-naive and
17
+ offset-aware `datetime` objects. We will also highlight the builtin
18
+ UTC timezone and show how it can be used to make the default `datetime`
19
+ object more powerful.
20
+ """
1
21
from datetime import datetime , timezone
2
22
3
23
You can’t perform that action at this time.
0 commit comments