diff --git a/src/event.py b/src/event.py index 7baae65..b68e30e 100644 --- a/src/event.py +++ b/src/event.py @@ -44,6 +44,7 @@ } } + def loadSZ(): szPath = "c:/temp/tpjson/sommerzeiten.json" global sommerzeiten @@ -56,6 +57,8 @@ def loadSZ(): # see https://stackoverflow.com/questions/4770297/convert-utc-datetime-string-to-local-datetime-with-python def convertToMEZOrMSZ(beginning): # '2018-04-29T06:30:00+00:00' + if beginning[10:19] == "T00:00:00": + return beginning[0:10] # without time, just return day # scribus/Python2 does not support %z beginning = beginning[0:19] # '2018-04-29T06:30:00' d = time.strptime(beginning, "%Y-%m-%dT%H:%M:%S") @@ -83,6 +86,13 @@ def convertToMEZOrMSZ(beginning): # '2018-04-29T06:30:00+00:00' return mez +def getTime(date): + # if convertToMEZOrMSZ returned only day, then time="" + if len(date) <= 16: + return "" + return date[11:16] + + class SAXHandler(xml.sax.handler.ContentHandler): def __init__(self): super().__init__() @@ -331,4 +341,3 @@ def getAnmeldung(self): def getTitel(self): return self.titel - diff --git a/src/eventXml.py b/src/eventXml.py index d08e082..6812a4e 100644 --- a/src/eventXml.py +++ b/src/eventXml.py @@ -105,7 +105,8 @@ def tourLoc(self, tl): beginning = tl.get("Beginning") logger.debug("beginning %s", beginning) # '2018-04-24T12:00:00' beginning = event.convertToMEZOrMSZ(beginning) # '2018-04-24T14:00:00' - beginning = beginning[11:16] # 14:00 + # TODO wt + beginning = event.getTime(beginning) # 14:00 name = tl.get("Name") street = tl.get("Street") city = tl.get("City") @@ -322,7 +323,7 @@ def getDatum(self): day = str(datum[0:10]) date = time.strptime(day, "%Y-%m-%d") weekday = event.weekdays[date.tm_wday] - res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], datum[11:16]) + res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], event.getTime(datum)) return res def getDatumRaw(self): @@ -335,7 +336,8 @@ def getEndDatum(self): day = str(datum[0:10]) date = time.strptime(day, "%Y-%m-%d") weekday = event.weekdays[date.tm_wday] - res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], datum[11:16]) + # TODO wt + res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], event.getTime(datum)) return res def getEndDatumRaw(self): @@ -433,7 +435,8 @@ def getAnmeldung(self): res += max if closDate is not None and closDate != "": closDate = event.convertToMEZOrMSZ(closDate) # '2018-04-24T14:00:00' - closDate = closDate[8:10] + "." + closDate[5:7] + "." + closDate[0:4] + " " + closDate[11:16] + closDate = closDate[8:10] + "." + closDate[5:7] + "." + closDate[0:4] + " " + event.getTime(closDate) + # TODO wt res += ", Anmeldeschluss: " + closDate + " (" + self.getDatum()[0][4:9] + ")" if rurl != "": res += ", extUrl=" + rurl diff --git a/src/expand.py b/src/expand.py index 995a17e..f64ceb2 100644 --- a/src/expand.py +++ b/src/expand.py @@ -146,9 +146,15 @@ def expAbfahrtenM(tour, _): afs = tour.getAbfahrten() if len(afs) == 0: return "" - s = afs[0][1] + " Uhr; " + afs[0][2] + if afs[0][1] != "": + s = afs[0][1] + " Uhr; " + afs[0][2] + else: + s = afs[0][2] for afx, af in enumerate(afs[1:]): - s = s + "\n " + str(afx + 2) + ". Startpunkt: " + afs[afx][1] + " Uhr;" + afs[afx][2] + if afs[afx][1] != "": + s = s + "\n " + str(afx + 2) + ". Startpunkt: " + afs[afx][1] + " Uhr;" + afs[afx][2] + else: + s = s + "\n " + str(afx + 2) + ". Startpunkt: " + afs[afx][2] return s diff --git a/src/tourRest.py b/src/tourRest.py index f427787..2708750 100644 --- a/src/tourRest.py +++ b/src/tourRest.py @@ -59,7 +59,7 @@ def getAbfahrten(self): beginning = tourLoc.get("beginning") logger.debug("beginning %s", beginning) # '2018-04-24T12:00:00' beginning = event.convertToMEZOrMSZ(beginning) # '2018-04-24T14:00:00' - beginning = beginning[11:16] # 14:00 + beginning = event.getTime(beginning) # 14:00 else: beginning = "" name = tourLoc.get("name") @@ -235,7 +235,7 @@ def getDatum(self): day = str(datum[0:10]) date = time.strptime(day, "%Y-%m-%d") weekday = event.weekdays[date.tm_wday] - res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], datum[11:16], datum) + res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], event.getTime(datum), datum) return res def getDatumRaw(self): @@ -250,7 +250,7 @@ def getEndDatum(self): day = str(enddatum[0:10]) date = time.strptime(day, "%Y-%m-%d") weekday = event.weekdays[date.tm_wday] - res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], enddatum[11:16]) + res = (weekday + ", " + day[8:10] + "." + day[5:7] + "." + day[0:4], event.getTime(enddatum)) return res def getEndDatumRaw(self): @@ -335,7 +335,7 @@ def getAnmeldung(self): res += str(max) if closDate is not None and closDate != "": closDate = event.convertToMEZOrMSZ(closDate) - closDate = closDate[8:10] + "." + closDate[5:7] + "." + closDate[0:4] + " " + closDate[11:16] + closDate = closDate[8:10] + "." + closDate[5:7] + "." + closDate[0:4] + " " + event.getTime(closDate) res += ", Anmeldeschluss: " + closDate + " (" + self.getDatum()[0][4:9] + ")" if rurl != "": res += ", extUrl=" + rurl