add reverse function
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# 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.
|
||||
|
||||
@@ -11,21 +10,31 @@ def stringToDate(date: str) -> QtCore.QDate:
|
||||
Returns:
|
||||
QtCore.QDate: the QDate object in string format DD.MM.yyyy
|
||||
"""
|
||||
|
||||
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")
|
||||
debugMessage(date=date)
|
||||
if not date:
|
||||
return ""
|
||||
if "." in date:
|
||||
# converts the date from dd.mm.yyyy to qdate
|
||||
datedata = date.split(".")
|
||||
day = datedata[0]
|
||||
month = datedata[1]
|
||||
year = datedata[2]
|
||||
return QtCore.QDate(int(year), int(month), int(day)) # .toString("dd.MM.yyyy")
|
||||
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")
|
||||
|
||||
Reference in New Issue
Block a user