Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion challenge.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down