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