diff --git a/src/components/services/OctoPrint.vue b/src/components/services/OctoPrint.vue
index 32effab3..719d7a93 100644
--- a/src/components/services/OctoPrint.vue
+++ b/src/components/services/OctoPrint.vue
@@ -12,9 +12,9 @@
{{ completion.toFixed() }}%
|
-
+
- {{ toTime(printTime) }}
+ {{ formatTime(printTime) }}
@@ -33,8 +33,8 @@
class="progress is-primary"
:value="completion"
max="100"
- :title="`${state} - ${completion.toFixed()}%, ${toTime(
- printTimeLeft,
+ :title="`${state} - ${completion.toFixed()}%, ${formatTime(
+ printTimeLeft
)} left`"
>
{{ completion }}%
@@ -115,9 +115,28 @@ export default {
console.error(e);
}
},
- toTime: function (timastamp) {
- return new Date(timastamp * 1000).toTimeString().substring(0, 5);
- },
+ formatTime: function (seconds) {
+ const days = Math.floor(seconds / 86400);
+ let remainingSeconds = seconds % 86400;
+ const hours = Math.floor(remainingSeconds / 3600);
+ remainingSeconds %= 3600;
+ const minutes = Math.floor(remainingSeconds / 60);
+ const secs = remainingSeconds % 60;
+
+ const formattedHrs = hours.toString().padStart(2, '0')
+ const formattedMins = minutes.toString().padStart(2, '0')
+ const formattedSecs = secs.toString().padStart(2, '0')
+
+ if (days > 0) {
+ return `${days}d ${formattedHrs}h ${formattedMins}m`;
+ } else if (hours > 0) {
+ return `${formattedHrs}h ${formattedMins}m ${formattedSecs}s`;
+ } else if (minutes > 0) {
+ return `${formattedMins}m ${formattedSecs}s`;
+ } else {
+ return `${secs} seconds`;
+ }
+ }
},
};