NR: Shorten times
This commit is contained in:
parent
267edd7c0b
commit
48fd351089
1 changed files with 3 additions and 1 deletions
|
@ -80,6 +80,7 @@ class Module(object):
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
def process(self, service):
|
def process(self, service):
|
||||||
|
ut_now = datetime.now().timestamp()
|
||||||
nonetime = {"orig": None, "datetime": None, "ut": 0,
|
nonetime = {"orig": None, "datetime": None, "ut": 0,
|
||||||
"short": "None", "prefix": '', "on_time": False,
|
"short": "None", "prefix": '', "on_time": False,
|
||||||
"estimate": False, "status": 4}
|
"estimate": False, "status": 4}
|
||||||
|
@ -105,6 +106,7 @@ class Module(object):
|
||||||
for k, a in times.items():
|
for k, a in times.items():
|
||||||
if not a["orig"]: continue
|
if not a["orig"]: continue
|
||||||
a["short"] = a["datetime"].strftime("%H%M") if len(a["orig"]) > 5 else a["orig"]
|
a["short"] = a["datetime"].strftime("%H%M") if len(a["orig"]) > 5 else a["orig"]
|
||||||
|
a["shortest"] = "%02d" % a["datetime"].minute if -300 < a["ut"]-ut_now < 1800 else a["short"]
|
||||||
a["prefix"] = k[2] + ("s" if k[0] == "s" else "")
|
a["prefix"] = k[2] + ("s" if k[0] == "s" else "")
|
||||||
a["estimate"] = k[0] == "e"
|
a["estimate"] = k[0] == "e"
|
||||||
a["on_time"] = a["ut"] - times["s"+ k[1:]]["ut"] < 300
|
a["on_time"] = a["ut"] - times["s"+ k[1:]]["ut"] < 300
|
||||||
|
@ -265,7 +267,7 @@ class Module(object):
|
||||||
"?" if "platformsAreUnreliable" in query and query["platformsAreUnreliable"] else '',
|
"?" if "platformsAreUnreliable" in query and query["platformsAreUnreliable"] else '',
|
||||||
t["times"][filter["type"]]["prefix"].replace(filter["type"][0], '') if not t["cancelled"] else "",
|
t["times"][filter["type"]]["prefix"].replace(filter["type"][0], '') if not t["cancelled"] else "",
|
||||||
Utils.color(colours[t["times"][filter["type"]]["status"]]),
|
Utils.color(colours[t["times"][filter["type"]]["status"]]),
|
||||||
t["times"][filter["type"]]["short"],
|
t["times"][filter["type"]]["shortest"],
|
||||||
Utils.color(Utils.FONT_RESET)
|
Utils.color(Utils.FONT_RESET)
|
||||||
) for t in trains_filtered])
|
) for t in trains_filtered])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue