diff --git a/doc/development/implementation/timemachine.rst b/doc/development/implementation/timemachine.rst index 28dc8e550..2ab906d73 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 9ed1cf986..1c4ab4f89 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