Debian Codegraph @

docs/modules/triggers/date.rst

raw
1 :mod:`apscheduler.triggers.date`
2 ================================
3
4 .. automodule:: apscheduler.triggers.date
5
6 API
7 ---
8
9 Trigger alias for :meth:`~apscheduler.schedulers.base.BaseScheduler.add_job`: ``date``
10
11 .. autoclass:: DateTrigger
12 :show-inheritance:
13
14
15 Introduction
16 ------------
17
18 This is the simplest possible method of scheduling a job. It schedules a job to be executed once at the specified time.
19 It is APScheduler's equivalent to the UNIX "at" command.
20
21 The ``run_date`` can be given either as a date/datetime object or text (in the
22 `ISO 8601 <https://en.wikipedia.org/wiki/ISO_8601>`_ format).
23
24
25 Examples
26 --------
27
28 ::
29
30 from datetime import date
31
32 from apscheduler.schedulers.blocking import BlockingScheduler
33
34
35 sched = BlockingScheduler()
36
37 def my_job(text):
38 print(text)
39
40 # The job will be executed on November 6th, 2009
41 sched.add_job(my_job, 'date', run_date=date(2009, 11, 6), args=['text'])
42
43 sched.start()
44
45
46 You can specify the exact time when the job should be run::
47
48 # The job will be executed on November 6th, 2009 at 16:30:05
49 sched.add_job(my_job, 'date', run_date=datetime(2009, 11, 6, 16, 30, 5), args=['text'])
50
51
52 The run date can be given as text too::
53
54 sched.add_job(my_job, 'date', run_date='2009-11-06 16:30:05', args=['text'])
55
56 To add a job to be run immediately::
57
58 # The 'date' trigger and datetime.now() as run_date are implicit
59 sched.add_job(my_job, args=['text'])