# import qdate from PyQt6 import QtCore from .debug import debugMessage def stringToDate(date: str) -> QtCore.QDate: """Takes an input string and returns a QDate object. Args: date (str): the string of the date in the database, format: WDay Month Day Year Returns: QtCore.QDate: the QDate object in string format DD.MM.yyyy """ debugMessage(date=date) if not date: return "" if isinstance(date, QtCore.QDate): return date else: datedata = date.split("-") day = datedata[2] month = datedata[1] year = datedata[0] return QtCore.QDate(int(year), int(month), int(day)) # else: # datedata = date.split(" ")[1:] # month = datedata[0] # day = datedata[1] # year = datedata[2] # month = month.replace("Jan", "01") # month = month.replace("Feb", "02") # month = month.replace("Mar", "03") # month = month.replace("Apr", "04") # month = month.replace("May", "05") # month = month.replace("Jun", "06") # month = month.replace("Jul", "07") # month = month.replace("Aug", "08") # month = month.replace("Sep", "09") # month = month.replace("Oct", "10") # month = month.replace("Nov", "11") # month = month.replace("Dec", "12") # return QtCore.QDate(int(year), int(month), int(day)).toString("dd.MM.yyyy")