time
time
#
Candidate future time slots: the instants a session could be captured at.
times lays slots out at a fixed resolution across a span; times_of_day
lays them on the requested hours of one day. Both start at start (now, by
default) and drop nothing but the past.
times(resolution=timedelta(minutes=5), span=timedelta(hours=24), start=None)
#
Generate candidate timestamps over a time span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
resolution
|
timedelta
|
Time between candidate slots. Defaults to 5 minutes. |
timedelta(minutes=5)
|
span
|
timedelta
|
Total time span to cover. Defaults to 24 hours. |
timedelta(hours=24)
|
start
|
datetime | None
|
Starting time. Defaults to now. |
None
|
Returns:
| Type | Description |
|---|---|
Array[datetime]
|
The instants from |
Array[datetime]
|
every |
Source code in capturegraph-recipes/capturegraph_recipes/scheduling/forecast/time.py
times_of_day(hours, start=None)
#
Generate candidate time slots at specific hours of the day.
Creates slots for today (the date of start) at the specified hours,
returning only those strictly after start. Slots already in the past
are dropped, so late in the day the result may be empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
hours
|
list[int]
|
List of hours (0-23) to generate slots for. |
required |
start
|
datetime | None
|
Starting time. Defaults to now. |
None
|
Returns:
| Type | Description |
|---|---|
Array[datetime]
|
The slots still ahead of |