time
time
#
Generate candidate future time slots.
Creates a list of candidate timestamps for the scheduler to choose from.
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]
|
List of datetime objects at the given resolution. |
Source code in capturegraph-lib/capturegraph/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]
|
List of datetime objects, sorted chronologically. |