Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save saumalya75/e0ea5643cced849ef4c923dd346e7e9d to your computer and use it in GitHub Desktop.
Save saumalya75/e0ea5643cced849ef4c923dd346e7e9d to your computer and use it in GitHub Desktop.
Helper function to handle date-time related configuration
def _get_timedelta(unit, value):
if unit.upper() == "DAYS":
return timedelta(days=value)
if unit.upper() == "MONTHS":
return timedelta(months=value)
if unit.upper() == "YEARS":
return timedelta(years=value)
if unit.upper() == "HOURS":
return timedelta(hours=value)
if unit.upper() == "MINUTES":
return timedelta(minutes=value)
if unit.upper() == "SECONDS":
return timedelta(seconds=value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment