26 lines
673 B
Python
26 lines
673 B
Python
# import qdate
|
|
from PyQt6 import QtCore
|
|
from src import log
|
|
|
|
|
|
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
|
|
"""
|
|
#log.debug(f"stringToDate: {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))
|