Skip to content

Instantly share code, notes, and snippets.

@kuharan
Created July 11, 2021 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kuharan/695268a23455fc1c40aaa8efa7125a61 to your computer and use it in GitHub Desktop.
Save kuharan/695268a23455fc1c40aaa8efa7125a61 to your computer and use it in GitHub Desktop.
def calculate_days_since_last_run(all_completed_runs):
for run in all_completed_runs:
dt1 = datetime.datetime.fromtimestamp(int(time.time()))
dt2 = datetime.datetime.fromtimestamp(run['endTime'])
rd = dateutil.relativedelta.relativedelta (dt1, dt2)
run['time_since_last_sucess_run'] = str(rd.years) + '-' + str(rd.months) + '-' + str(rd.days) + '-' + str(rd.hours) + '-' + str(rd.minutes)
return all_completed_runs
all_completed_runs = calculate_days_since_last_run(all_completed_runs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment