CalendarJS icon indicating copy to clipboard operation
CalendarJS copied to clipboard

Week days starting on Monday

Open Dybrylla opened this issue 6 years ago • 2 comments

I came accross your calendar and it is exactly what ive been looking for, but is there a way the calendar can start on a Monday rather than Sunday?

Dybrylla avatar Oct 28 '19 08:10 Dybrylla

not currently, but i've been meaning to re-write this and when i do i'll be sure to add that.

Pamblam avatar Oct 28 '19 16:10 Pamblam

it is possible with only few code changes in calendar.js

change the lines (62, 63):

...
this.daysOfWeekFull = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
this.daysOfWeekAbbr = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
...

to

...
this.daysOfWeekFull = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
this.daysOfWeekAbbr = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
...

and insert firstDayofWeek = (firstDayofWeek + 6) % 7; after line 280

...
var firstDayofWeek = new Date(this.year, this.month, 1).getDay(),
        lastDate = new Date(this.year, this.month + 1, 0).getDate(),
        currentDate = 1,
        currentDay = 0,
        currentWeek = 0;
firstDayofWeek = (firstDayofWeek + 6) % 7;  // this is the line to insert
// draw title bar
...

juri117 avatar Feb 06 '22 18:02 juri117