Skip to content

Commit 00a4fd5

Browse files
committed
✏️ Switch to 'Import datetime as dt'
1 parent 84f64c3 commit 00a4fd5

4 files changed

Lines changed: 15 additions & 14 deletions

File tree

docs/appendix/checks.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,8 @@ Checks
430430

431431
.. code-block:: pycon
432432
433-
>>> import datetime
434-
>>> current = datetime.datetime.now()
433+
>>> import datetime as dt
434+
>>> current = dt.datetime.now()
435435
>>> year = current.year
436436
>>> year_birth = input("Geburtsjahr? ")
437437
Geburtsjahr? 1964
@@ -444,8 +444,8 @@ Checks
444444

445445
.. code-block:: pycon
446446
447-
>>> import datetime
448-
>>> current = datetime.datetime.now()
447+
>>> import datetime as dt
448+
>>> current = dt.datetime.now()
449449
>>> year = current.year
450450
>>> year_birth = float(input("Geburtsjahr: "))
451451
Geburtsjahr: 1964
@@ -456,8 +456,8 @@ Checks
456456

457457
.. code-block:: pycon
458458
459-
>>> import datetime
460-
>>> current = datetime.datetime.now()
459+
>>> import datetime as dt
460+
>>> current = dt.datetime.now()
461461
>>> year = current.year
462462
>>> year_birth = int(input("Geburtsjahr: "))
463463
Geburtsjahr: Schaltjahr
@@ -1082,12 +1082,12 @@ Checks
10821082
.. code-block:: pycon
10831083
:linenos:
10841084
1085-
>>> import datetime
1085+
>>> import datetime as dt
10861086
>>> import pathlib
10871087
>>> import zipfile
10881088
>>> file_pattern = "*.txt"
10891089
>>> archive_path = "archive"
1090-
>>> today = f"{datetime.date.today():%Y-%m-%d}"
1090+
>>> today = f"{dt.date.today():%Y-%m-%d}"
10911091
>>> cur_path = pathlib.Path(".")
10921092
>>> paths = cur_path.glob(file_pattern)
10931093
>>> zip_path = cur_path.joinpath(archive_path, today + ".zip")

docs/test/mock.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ Example
3030
First, we wanted to start with a simple example and check whether the working
3131
days from Monday to Friday are determined correctly.
3232

33-
#. First, we import ``datetime.datetime`` and ``Mock``:
33+
#. First, we import :class:`datetime.datetime` and :class:`Mock
34+
<python3:unittest.mock.Mock>`:
3435

3536
.. literalinclude:: test_mock.py
3637
:language: python

docs/types/strings/input.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ with the :class:`python3:int` or :class:`python3:float` function, for example, f
1919

2020
.. code-block:: pycon
2121
22-
>>> import datetime
22+
>>> import datetime as dt
2323
>>>
24-
>>> currentDateTime = datetime.datetime.now()
24+
>>> currentDateTime = dt.datetime.now()
2525
>>> year = currentDateTime.year
2626
>>> year_birth = input("Year of birth? ")
2727
Year of birth? 1964

docs/types/strings/print.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,12 @@ objects.
214214

215215
.. code-block:: pycon
216216
217-
>>> import datetime
217+
>>> import datetime as dt
218218
>>> import locale
219219
>>> locale.setlocale(locale.LC_TIME, "de_DE.utf-8")
220220
... "de_DE.utf-8"
221221
'de_DE.utf-8'
222-
>>> today = datetime.date.today()
222+
>>> today = dt.date.today()
223223
>>> print(f"Heute ist {today:%A, %d. %B %Y}.")
224224
Heute ist Freitag, 11. Juli 2025.
225225
@@ -229,7 +229,7 @@ Conversely, you can also use :meth:`datetime.strptime
229229
.. code-block:: pycon
230230
231231
>>> today_string = "Fri, 11 Jul 2025 18:46:49"
232-
>>> today = datetime.datetime.strptime(today_string, "%A, %d. %B %Y")
232+
>>> today = dt.datetime.strptime(today_string, "%A, %d. %B %Y")
233233
234234
.. csv-table:: Häufige Formatierungen
235235
:header: "Beschreibung", "Beispiel", "Format"

0 commit comments

Comments
 (0)