From 121181c6a1c110d2c3b31ca71bc4398e50f10323 Mon Sep 17 00:00:00 2001 From: Trent Larson Date: Tue, 2 Apr 2024 18:38:44 -0600 Subject: [PATCH] add adjustment to UTC hour for notification time --- src/App.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/App.vue b/src/App.vue index d4f9aa0b6..e133ab1d4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -513,7 +513,7 @@ export default class App extends Vue { ); return false; } - if (hourNum < 1 || hourNum > 12) { + if (hourNum < 1 || 12 < hourNum) { this.$notify( { group: "alert", @@ -554,15 +554,21 @@ export default class App extends Vue { -1, ); // we already checked that this is a valid hour number - const hourNum = libsUtil.numberOrZero(this.hourInput); + const rawHourNum = libsUtil.numberOrZero(this.hourInput); + const adjHourNum = rawHourNum + (this.hourAm ? 0 : 12); + const hourNum = adjHourNum % 24; const utcHour = hourNum + Math.round(new Date().getTimezoneOffset() / 60); + const finalUtcHour = (utcHour + (utcHour < 0 ? 24 : 0)) % 24; // This ignore commentary is because I'm adding non-standard stuff to the subscription object. // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore - subscription.notifyTime = { utcHour: utcHour }; - this.sendSubscriptionToServer(subscription); + const subscriptionWithTime = { + notifyTime: { utcHour: finalUtcHour }, + ...subscription, + }; + this.sendSubscriptionToServer(subscriptionWithTime); return subscription; } else { throw new Error("Subscription object is not available.");