Skip to main content
Version: devel

dlt.common.interval

is_cron_expression

def is_cron_expression(s: str) -> bool

View source on GitHub

Check whether a string is a valid cron expression.

Arguments:

  • s str - The string to validate.

Returns:

  • bool - True if s parses as a cron expression.

lag_cron

def lag_cron(cron_expr: str, dt: datetime, count: int) -> datetime

View source on GitHub

Floor dt to the latest cron tick, then step count ticks into the past.

Ticks are computed on the naive wall clock of dt's timezone, so daily and sub-daily expressions align correctly across DST transitions.

Arguments:

  • cron_expr str - A cron expression defining the tick grid.
  • dt datetime - The reference time. Its timezone is preserved on the result.
  • count int - Number of ticks to step back. count=0 returns the floor tick (dt itself when it falls on a tick); negative values step into the future (count=-1 is the first tick strictly after the floor).

Returns:

  • datetime - The resulting tick, carrying dt's timezone.

lag_interval

def lag_interval(interval: TTimeInterval,
trigger: str,
count: int = 1,
lag_end: bool = False) -> TTimeInterval

View source on GitHub

Lag the interval start (or end) by count trigger ticks into the past.

count=0 snaps the bound to the tick floor, negative count moves it into the future. For every: triggers the bound shifts by period * count seconds.

Arguments:

  • interval TTimeInterval - The interval to adjust.
  • trigger str - A schedule: or every: trigger, or a bare cron expression.
  • count int - Number of ticks (or periods) to lag; negative moves into the future. Defaults to 1.
  • lag_end bool - When True, adjusts the end instead of the start. Defaults to False.

Returns:

  • TTimeInterval - The adjusted interval.

Raises:

  • ValueError - If the adjusted interval is empty or negative, or if the trigger carries no time period (not a schedule:/every: trigger or cron expression).

full_days_interval

def full_days_interval(interval: TTimeInterval) -> TTimeInterval

View source on GitHub

Widen an interval so it covers whole days.

The start is floored to the midnight at or before it and the end raised to the midnight at or after it, each adjusted in its own timezone.

Arguments:

  • interval TTimeInterval - The interval to widen.

Returns:

  • TTimeInterval - The widened interval.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.