Solución
solution.tsTypeScript
from datetime import datetime
def parse_flexible_date(date_str: str) -> dict:
# Intenta parsear el string con dos formatos distintos
try:
date = datetime.strptime(date_str, "%Y-%m-%d")
except ValueError as e:
date = datetime.strptime(date_str, "%d/%m/%Y")
return {"year": date.year, "month": date.month, "day": date.day}0respuestas