Browse Source

add adjustment to UTC hour for notification time

pull/1/head
Trent Larson 6 months ago
parent
commit
121181c6a1
  1. 14
      src/App.vue

14
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.");

Loading…
Cancel
Save