Adds refresh button to widget, for reloading data

This commit is contained in:
Alicia Sykes
2021-12-13 16:22:24 +00:00
parent ae8179ecd7
commit 2075cbc222
18 changed files with 254 additions and 49 deletions

View File

@@ -39,8 +39,12 @@ export default {
},
},
methods: {
update() {
this.setTime();
this.setDate();
},
/* Get and format the current time */
updateTime() {
setTime() {
this.time = Intl.DateTimeFormat(this.timeFormat, {
timeZone: this.timeZone,
hour: 'numeric',
@@ -49,7 +53,7 @@ export default {
}).format();
},
/* Get and format the date */
updateDate() {
setDate() {
this.date = new Date().toLocaleDateString(this.timeFormat, {
weekday: 'long', day: 'numeric', year: 'numeric', month: 'short',
});
@@ -57,14 +61,13 @@ export default {
},
created() {
// Set initial date and time
this.updateTime();
this.updateDate();
this.update();
// Update the date every hour, and the time each second
this.timeUpdateInterval = setInterval(() => {
this.updateTime();
this.setTime();
const now = new Date();
if (now.getMinutes() === 0 && now.getSeconds() === 0) {
this.updateDate();
this.setDate();
}
}, 1000);
},