From a49d3dbd8ec654834d86d4e7bdba6aca0c7775b3 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Thu, 30 Nov 2017 11:57:14 +0100 Subject: [PATCH] Added missing time/date completed CL-541 --- .../UM3NetworkPrinting/ClusterUM3OutputDevice.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py index 7d459abf4c..76d4c70752 100644 --- a/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py +++ b/plugins/UM3NetworkPrinting/ClusterUM3OutputDevice.py @@ -18,7 +18,7 @@ from PyQt5.QtGui import QDesktopServices from PyQt5.QtCore import pyqtSlot, QUrl, pyqtSignal, pyqtProperty from time import time - +from datetime import datetime import json import os @@ -171,6 +171,19 @@ class ClusterUM3OutputDevice(NetworkedPrinterOutputDevice): def formatDuration(self, seconds): return Duration(seconds).getDisplayString(DurationFormat.Format.Short) + @pyqtSlot(int, result=str) + def getTimeCompleted(self, time_remaining): + current_time = time() + datetime_completed = datetime.fromtimestamp(current_time + time_remaining) + return "{hour:02d}:{minute:02d}".format(hour=datetime_completed.hour, minute=datetime_completed.minute) + + @pyqtSlot(int, result=str) + def getDateCompleted(self, time_remaining): + current_time = time() + datetime_completed = datetime.fromtimestamp(current_time + time_remaining) + + return (datetime_completed.strftime("%a %b ") + "{day}".format(day=datetime_completed.day)).upper() + def _update(self): if not super()._update(): return