round_datetime_down#

round_datetime_down(ts, delta, offset=datetime.timedelta(0))[source]#

Snap to previous available timedelta.

Preserve any timezone info on ts.

If we are at the the given exact delta, then do not round, only add offset.

Parameters:
  • ts (datetime) – Timestamp we want to round

  • delta (timedelta) – Our snap grid

  • offset (timedelta) – Add a fixed time offset at the top of rounding

Returns:

When to wake up from the sleep next time

Return type:

datetime