Skip to content

Instantly share code, notes, and snippets.

@Park-Developer
Created August 10, 2022 13:56
Show Gist options
  • Save Park-Developer/83e0f6bfd19d255f8c135218720180fc to your computer and use it in GitHub Desktop.
Save Park-Developer/83e0f6bfd19d255f8c135218720180fc to your computer and use it in GitHub Desktop.
Calculate time
def calc_timeDelta(reference_time:str,days,hours,minutes,time_format)->str:
calced_time=datetime.strptime(reference_time,time_format)+timedelta(days=days,minutes=minutes,hours=hours)
return calced_time
# test
time_format="%Y-%m-%d %H:%M:%S"
print(calc_timeDelta(reference_time='2022-08-10 22:10:49',days=-10,hours=21,minutes=3,time_format=time_format))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment