Skip to content

Commit 95b6d6a

Browse files
committed
Add module docstring to date_time
1 parent cf47a9a commit 95b6d6a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

ultimatepython/advanced/date_time.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
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+
"""
121
from datetime import datetime, timezone
222

323

0 commit comments

Comments
 (0)