def IsTimeDelta(dt1, dt2, seconds=None, minutes=None, hours=None, days=None):
  delta = abs(dt2 - dt1)
  if days is not None:
    dseconds = days * 86400
  elif hours is not None:
    dseconds = hours * 3600
  elif minutes is not None:
    dseconds = minutes * 60
  elif seconds is not None:
    dseconds = seconds
  else:
    return

  if ((delta.days * 86400) + delta.seconds) <= dseconds:
    return delta
Returns delta if datetime values are within a time period.
dataset/ETHPy150Open google/simian/src/simian/mac/cron/reports_cache.py/IsTimeDelta