mirror of https://github.com/Lissy93/dashy.git
🩹 Fixes clock date update delay at midnight (#402)
This commit is contained in:
parent
3a3364f156
commit
8b1282c5e1
|
@ -15,9 +15,9 @@ export default {
|
||||||
mixins: [WidgetMixin],
|
mixins: [WidgetMixin],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
timeUpdateInterval: null, // Stores setInterval function
|
|
||||||
time: null, // Current time string
|
time: null, // Current time string
|
||||||
date: null, // Current date string
|
date: null, // Current date string
|
||||||
|
timeUpdateInterval: null, // Stores setInterval function
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -61,16 +61,11 @@ export default {
|
||||||
created() {
|
created() {
|
||||||
// Set initial date and time
|
// Set initial date and time
|
||||||
this.update();
|
this.update();
|
||||||
// Update the date every hour, and the time each second
|
// Update the time and date every second (1000 ms)
|
||||||
this.timeUpdateInterval = setInterval(() => {
|
this.timeUpdateInterval = setInterval(this.update, 1000);
|
||||||
this.setTime();
|
|
||||||
const now = new Date();
|
|
||||||
if (now.getMinutes() === 0 && now.getSeconds() === 0) {
|
|
||||||
this.setDate();
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
|
// Remove the clock interval listener
|
||||||
clearInterval(this.timeUpdateInterval);
|
clearInterval(this.timeUpdateInterval);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -102,6 +97,7 @@ export default {
|
||||||
font-size: 4rem;
|
font-size: 4rem;
|
||||||
padding: 0.5rem;
|
padding: 0.5rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
font-family: Digital, var(--font-monospace);
|
font-family: Digital, var(--font-monospace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue