Skip to content

Commit

Permalink
Maybe actually fixed notifications this time
Browse files Browse the repository at this point in the history
Fixes #16
  • Loading branch information
aopell committed Dec 15, 2017
1 parent a7f666d commit a80b976
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ function onAlarm(alarm) {
let assignments = notification.getElementsByTagName("a");
let extraTextElement = notification.querySelector(".other-items-link");
let timeText = notification.querySelector(".edge-time").textContent;
let monthDay = timeText.split(" at ")[0];
let splitDate = timeText.split(" at ");
let monthDay = splitDate[0];
let hourMinute = splitDate[1];
let now = new Date();
let monthDayYear = monthDay + ` ${now.getFullYear()}`;
let today = `${months[now.getMonth()]} ${now.getDate()} ${now.getFullYear()}`;
let notificationDate = Date.parse(monthDayYear);
if (notificationDate > Date.parse(today)) {
notificationDate = Date.parse(monthDay + ` ${now.getFullYear() - 1}`);
notificationDate = Date.parse(monthDay + ` ${now.getFullYear() - 1} ${hourMinute}`);
} else {
notificationDate = Date.parse(`${monthDayYear} ${hourMinute}`);
}

if (notificationDate > time) {
Expand Down

0 comments on commit a80b976

Please sign in to comment.