Last active
May 29, 2020 06:22
-
-
Save saumalya75/e0ea5643cced849ef4c923dd346e7e9d to your computer and use it in GitHub Desktop.
Helper function to handle date-time related configuration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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