Temporal Combinators¶
during_hours¶
during_hours(
start: int,
end: int,
tz: tzinfo | None = None,
inclusive_end: bool = False,
) -> Predicate
Check if the current hour is within the given range.
start/end-- Hours (0-23)tz-- Optional timezone (defaults to local time)inclusive_end-- IfTrue, include the end hour
Supports overnight ranges (e.g. during_hours(22, 6) for 10 PM to 5:59 AM).
from kompoz import during_hours
business_hours = during_hours(9, 17)
night_mode = during_hours(22, 6)
full_hours = during_hours(9, 17, inclusive_end=True)
on_weekdays¶
Check if today is Monday through Friday.
tz-- Optional timezone name (defaults to local time)
from kompoz import on_weekdays
weekdays = on_weekdays()
weekdays_ny = on_weekdays(tz="America/New_York")
on_days¶
Check if today is one of the specified days. Days use Monday=0, Sunday=6.
tz-- Optional timezone name (defaults to local time)
from kompoz import on_days
mwf = on_days(0, 2, 4) # Mon, Wed, Fri
weekends = on_days(5, 6) # Sat, Sun
weekends_tokyo = on_days(5, 6, tz="Asia/Tokyo")
after_date¶
Check if today is after the given date (not inclusive).
tz-- Optional timezone name (defaults to local time)
from kompoz import after_date
launched = after_date(2024, 6, 1)
launched_jp = after_date(2024, 6, 1, tz="Asia/Tokyo")
before_date¶
Check if today is before the given date (not inclusive).
tz-- Optional timezone name (defaults to local time)
between_dates¶
Check if today is within the date range (inclusive).
tz-- Optional timezone name (defaults to local time)