From 20e71a573ffb64773b020bd91e625d075a5c4452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20=C3=81ngel?= <20430676+supermavster@users.noreply.github.com> Date: Sat, 27 Jun 2020 18:06:21 -0500 Subject: [PATCH] [Complete] Challenge 08 Python! --- challenge.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/challenge.py b/challenge.py index c69287d..9133e20 100644 --- a/challenge.py +++ b/challenge.py @@ -1,8 +1,25 @@ import time +from datetime import datetime -def finish_date(): +def finish_date(func): # You have to code here!! + # Debe modificar el comportamiento de una función de cualquier tipo añadiendo al final un print en consola que indique la fecha y hora en la que terminó de ejecutarse la función, en el formato `dd/mm/YYYY - HH:MM:SS` + def wrapper(*args, **kwargs): + # Initial Date + initial_time = time.time() + # Execute function + func(*args, **kwargs) + # End Date + final_time = time.time() + # Convert format Date + initial_time = datetime.fromtimestamp( + initial_time).strftime("%d/%m/%Y - %H:%M:%S") + final_time = datetime.fromtimestamp( + final_time).strftime("%d/%m/%Y - %H:%M:%S") + print( + f'The function {func.__name__} took {initial_time} to {final_time}') + return wrapper @finish_date