From 0b13d86fc25633bac694d2d7da92111082b1ec9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Sat, 21 Nov 2015 14:30:53 +0100 Subject: [PATCH] Version 15.41 --- js/swad.js | 51 +++++++++++++++++++++++++----------------------- swad_calendar.c | 8 ++++++-- swad_changelog.h | 3 ++- 3 files changed, 35 insertions(+), 27 deletions(-) diff --git a/js/swad.js b/js/swad.js index 70ab38e7b..b407f2028 100644 --- a/js/swad.js +++ b/js/swad.js @@ -619,7 +619,7 @@ function disableDetailedClicks() { /************************ Draw an academic calendar **************************/ /*****************************************************************************/ -function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView, +function Cal_DrawCalendar (id,Sunday,TimeUTC,CurrentPlcCod,PrintView, CGI,FormGoToCalendarParams,FormEventParams) { var StartingMonth = [ // Calendar starts one row before current month 9, // January --> September @@ -633,7 +633,7 @@ function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView, 5, // September --> May 5, // October --> May 5, // November --> May - 5 // December --> May + 5 // December --> May ]; var d = new Date; d.setTime(TimeUTC * 1000); @@ -662,9 +662,9 @@ function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView, MonthId = id + '_month_' + MonthIdNum; Gbl_HTMLContent += ''; - DrawMonth(MonthId, Year, Month, CurrentMonth, CurrentDay, - CurrentPlcCod, true, PrintView, CGI, - FormGoToCalendarParams, FormEventParams); + DrawMonth (MonthId,Sunday,Year,Month,CurrentMonth,CurrentDay, + CurrentPlcCod,true,PrintView,CGI, + FormGoToCalendarParams,FormEventParams); Gbl_HTMLContent += ''; if (++Month == 13) { Month = 1; @@ -682,7 +682,7 @@ function Cal_DrawCalendar (id,TimeUTC,CurrentPlcCod,PrintView, /***************************** Draw current month ****************************/ /*****************************************************************************/ -function DrawCurrentMonth (id,TimeUTC,CurrentPlcCod, +function DrawCurrentMonth (id,Sunday,TimeUTC,CurrentPlcCod, CGI,FormGoToCalendarParams,FormEventParams) { var d = new Date; d.setTime(TimeUTC * 1000); @@ -690,17 +690,20 @@ function DrawCurrentMonth (id,TimeUTC,CurrentPlcCod, var Month = d.getMonth() + 1; var CurrentDay = d.getDate(); - DrawMonth(id,Year,Month,Month,CurrentDay,CurrentPlcCod,false,false, - CGI,FormGoToCalendarParams,FormEventParams); + DrawMonth (id,Sunday,Year,Month,Month,CurrentDay, + CurrentPlcCod,false,false, + CGI,FormGoToCalendarParams,FormEventParams); document.getElementById(id).innerHTML = Gbl_HTMLContent; } /*****************************************************************************/ -/******************************** Draw a month *******************************/ +/******************************* Draw a month ********************************/ /*****************************************************************************/ +// Sunday == 0 ==> Sunday is the first day of the week +// Sunday == 6 ==> Sunday is the last day of the week -function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlcCod, - DrawingCalendar,PrintView, +function DrawMonth (id,Sunday,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay, + CurrentPlcCod,DrawingCalendar,PrintView, CGI,FormGoToCalendarParams,FormEventParams) { var NumDaysMonth = [ 0, @@ -747,7 +750,7 @@ function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlc If it's 0 then write 1 box of the previous month. If it's 1 then write 0 boxes of the previous month. */ - if ((DayOfWeek = GetDayOfWeek(Yea, Mon, 1)) == 0) + if ((DayOfWeek = (GetDayOfWeekMondayFirst (Yea,Mon,1) + Sunday + 1) % 7) == 0) Day = 1; else { if (Mon <= 1) { @@ -784,10 +787,10 @@ function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlc Gbl_HTMLContent += '' + ''; for (DayOfWeek = 0; DayOfWeek < 7; DayOfWeek++) Gbl_HTMLContent += ''; Gbl_HTMLContent += ''; @@ -837,7 +840,7 @@ function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlc } /* Day being drawn is sunday? */ - if (DayOfWeek == 6) // All the sundays are holidays + if (DayOfWeek == Sunday) // All the sundays are holidays ClassForDay = (Mon == MonthToDraw) ? 'DAY_HLD' : 'DAY_HLD_LIGHT'; @@ -922,16 +925,16 @@ function DrawMonth (id,YearToDraw,MonthToDraw,CurrentMonth,CurrentDay,CurrentPlc } /*****************************************************************************/ -/***************** Compute day of the week from a given date *****************/ +/* Compute day of the week from a given date (monday as first day of a week) */ /*****************************************************************************/ // Return 0 for monday, 1 for tuesday,... 6 for sunday -function GetDayOfWeek (Year,Month,Day) { - if (Month <= 2) { - Month += 12; - Year--; - } - return (((Day + +function GetDayOfWeekMondayFirst (Year,Month,Day) { + if (Month <= 2) { + Month += 12; + Year--; + } + return (((Day + (Month * 2) + Math.floor (((Month + 1) * 3) / 5) + Year + @@ -940,7 +943,7 @@ function GetDayOfWeek (Year,Month,Day) { Math.floor (Year/400) + 2) % 7) + 5) % 7; } - + /*****************************************************************************/ /****************** Return the number of days of february ********************/ /*****************************************************************************/ diff --git a/swad_calendar.c b/swad_calendar.c index af772711f..57546b20f 100644 --- a/swad_calendar.c +++ b/swad_calendar.c @@ -52,6 +52,7 @@ void Cal_DrawCurrentMonth (void) { extern const char *Txt_STR_LANG_ID[Txt_NUM_LANGUAGES]; char Params[256+256+Ses_LENGTH_SESSION_ID+256]; + unsigned Sunday = 6; /***** Get list of holidays *****/ if (!Gbl.Hlds.LstIsRead) @@ -71,7 +72,8 @@ void Cal_DrawCurrentMonth (void) /* Write script to draw the month */ fprintf (Gbl.F.Out,"
' + - DAYS_CAPS[DayOfWeek] + + DAYS_CAPS[(DayOfWeek + 6 - Sunday) % 7] + '