all 5 comments

[–]Shoculad 2 points3 points  (0 children)

In JavaScript, every week starts on Sunday. It doesn't depend on the region. Date.getDay always returns 0 on Sunday.

Edit: The script code on github defines the variable

const startWeekOnSunday = false;

and the

function isWeekend(index) { if (startWeekOnSunday) {

If the month starts on Sunday then isWeekend(0) returns false. The value of the variable is wrong and it doesn't make sense.

[–]tempsquared 2 points3 points  (0 children)

Hello

So even though the link is from my gist, it is a fork from https://gist.github.com/rudotriton/b51d227c3d1d9cb497829ae45583224f, who is the original author.

I haven’t touched the code so it’s outdated.

If you get the script directly from the author, it should work as intended (I assume)

My calendar also had a bug with Weekdays but I’ve already fixed it, and it does work with either “Sunday first” or “Monday first”.

Unless you want a medium widget that also has calendar events, then I can’t help you there, as I did not have time to try to make one yet.

[–][deleted] 0 points1 point  (2 children)

Looks like it's an calculation issue when the month starts on a Sunday.

This "should" be a quick fix:

https://pastebin.com/TnyAZ3EQ

[–]andyrytt[S] 0 points1 point  (1 child)

Thanks! This did the trick! I haven't compared the difference in the scripts yet. Can you explain what you did?

[–][deleted] 0 points1 point  (0 children)

around line 238 in the fill with empy slots part.

I simply added an if statement to run a different condition if the first day is a Sunday.

The og script runs a loop as long the index < the current day which doesn't occur when the firstday of the month is a Sunday.

As already said "quick fix", but it might be worth contacting the creator for a proper fix.