Skip to content

Bug: Incorrect Weekend Handling Causes Undefined Access on Sundays #58

@ritgit24

Description

@ritgit24

Description

The extension uses Date.getDay() to determine the current day of the week. However, the current weekend check incorrectly handles Sundays, leading to undefined access and background script errors.

In JavaScript:

  • getDay() returns 0 for Sunday
  • 1–5 for Monday–Friday
  • 6 for Saturday

The existing condition:
line 113

if (currentDate.getDay() > 5) {
  return;
}

only excludes Saturday (6) but allows Sunday (0) to pass through.

Due to same error ,
line 68

function setNotification(){
  chrome.storage.local.get(['timetable'], function(result) {
    let currentDate = new Date()
    if(currentDate.getDay() > 5){
      return
    }
    let storedData = result.timetable
    storedData = Convert(storedData)
    let x = storedData[Day(currentDate.getDay()-1)]
    let p = 1
    for(let i=0; i<x.length; i++){
      const ClassTime = new Date(x[i].time)
      title = x[i].title
      if(calculateTimeDifference(ClassTime, 0)){
        p = 0
        if(calculateTimeDifference(ClassTime,0) < 15*60*1000){
          Notify_urgent(ClassTime, title);
          return

an undefined error is thrown in the background for the line
let x = storedData[Day(currentDate.getDay()-1)] as 0 for Sunday is also included(segmentation fault).

Metadata

Metadata

Assignees

Labels

WOCWinter of CodebugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions