Browse Source

add adjustment to UTC hour for notification time

pull/1/head
Trent Larson 7 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; return false;
} }
if (hourNum < 1 || hourNum > 12) { if (hourNum < 1 || 12 < hourNum) {
this.$notify( this.$notify(
{ {
group: "alert", group: "alert",
@ -554,15 +554,21 @@ export default class App extends Vue {
-1, -1,
); );
// we already checked that this is a valid hour number // 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 = const utcHour =
hourNum + Math.round(new Date().getTimezoneOffset() / 60); 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. // This ignore commentary is because I'm adding non-standard stuff to the subscription object.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore // @ts-ignore
subscription.notifyTime = { utcHour: utcHour }; const subscriptionWithTime = {
this.sendSubscriptionToServer(subscription); notifyTime: { utcHour: finalUtcHour },
...subscription,
};
this.sendSubscriptionToServer(subscriptionWithTime);
return subscription; return subscription;
} else { } else {
throw new Error("Subscription object is not available."); throw new Error("Subscription object is not available.");

Loading…
Cancel
Save