From 569f1719b07a668e7d158b3ecfc6129f1167d444 Mon Sep 17 00:00:00 2001 From: Mira Weller Date: Mon, 15 Apr 2024 17:32:42 +0200 Subject: [PATCH] add documentation --- doc/development/implementation/timemachine.rst | 2 ++ src/pretix/base/timemachine.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/doc/development/implementation/timemachine.rst b/doc/development/implementation/timemachine.rst index 28dc8e5501..2ab906d73e 100644 --- a/doc/development/implementation/timemachine.rst +++ b/doc/development/implementation/timemachine.rst @@ -10,6 +10,8 @@ product can be bought, you should use :py:meth:`time_machine_now`. .. autofunction:: pretix.base.timemachine.time_machine_now +.. autofunction:: pretix.base.timemachine.time_machine_now_assigned + Background tasks ---------------- diff --git a/src/pretix/base/timemachine.py b/src/pretix/base/timemachine.py index 9ed1cf986a..1c4ab4f89f 100644 --- a/src/pretix/base/timemachine.py +++ b/src/pretix/base/timemachine.py @@ -60,6 +60,11 @@ def time_machine_now(default=False): @contextmanager def time_machine_now_assigned(now_dt): + """ + Use this context manager to assign current datetime for time machine mode. Useful e.g. for background tasks. + + :param now_dt: The datetime value to assign. May be `None` to disable time machine. + """ try: timemachine_now_var.set(now_dt) yield