From d10ff995bce0536f065caa2e5d11e86f22f303ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Fri, 5 May 2017 02:03:28 +0200 Subject: [PATCH] Version 16.206 --- js/{swad16.205.js => swad16.206.js} | 4 ++-- swad_changelog.h | 6 +++--- swad_constant.h | 4 ++-- swad_date.c | 29 +++++++++++++++++++++++++---- swad_date.h | 4 +++- swad_exam.c | 14 ++++++++------ swad_holiday.c | 19 ++++++++----------- swad_statistic.c | 28 ++++++++++++++++++---------- 8 files changed, 69 insertions(+), 39 deletions(-) rename js/{swad16.205.js => swad16.206.js} (99%) diff --git a/js/swad16.205.js b/js/swad16.206.js similarity index 99% rename from js/swad16.205.js rename to js/swad16.206.js index 3e79d2fd..ad3cf1ca 100644 --- a/js/swad16.205.js +++ b/js/swad16.206.js @@ -103,10 +103,10 @@ function writeLocalDateHMSFromUTC (id,TimeUTC,DateFormat,Separator,StrToday, StrDate = Yea.toString() + '-' + StrMon + '-' + StrDay; break; case 1: // Dat_FORMAT_DD_MONTH_YYYY - StrDate = Day.toString() + ' ' + MonthsShort[Mon - 1] + ' ' + Yea.toString(); + StrDate = Day.toString() + ' ' + MonthsShort[Mon - 1] + ' ' + Yea.toString(); break; case 2: // Dat_FORMAT_MONTH_DD_YYYY - StrDate = MonthsShort[Mon - 1] + ' ' + Day.toString() + ', ' + Yea.toString(); + StrDate = MonthsShort[Mon - 1] + ' ' + Day.toString() + ', ' + Yea.toString(); break; default: StrDate = ''; diff --git a/swad_changelog.h b/swad_changelog.h index d41a778a..952f6e9d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -217,7 +217,6 @@ // TODO: Change numbers of notifications in program and database to match order in tabs // TODO: Sugerencias de Sandra Daniela Tazzioli Barroso realizadas el 2 de mayo de 2017: -// 1. Poder ver fechas en formato (día-mes-año). // 2. Mejor ayuda sobre cómo pasar de Excel al formato HTML necesario para las calificaciones. // 3. Puede ser interesante que un administrador pueda cambiar el DNI de un usuario. // 4. Comprobar que las direcciones de correo de cada uno de los estudiantes aparecen en Bcc: (copia oculta) en cualquier gestor de correo. @@ -233,13 +232,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.205.4 (2017-05-05)" +#define Log_PLATFORM_VERSION "SWAD 16.206 (2017-05-05)" #define CSS_FILE "swad16.205.css" -#define JS_FILE "swad16.205.js" +#define JS_FILE "swad16.206.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 16.206: May 05, 2017 Date format applied to dates written directly instead of using Javascript. (218514 lines) Version 16.205.4: May 05, 2017 Help about date format. (218487 lines) Version 16.205.3: May 04, 2017 Changes in statistics about date format. (218447 lines) Version 16.205.2: May 04, 2017 Changes in form to select date format. (218439 lines) diff --git a/swad_constant.h b/swad_constant.h index bcfd3433..acbe5586 100644 --- a/swad_constant.h +++ b/swad_constant.h @@ -42,8 +42,8 @@ // 123456789012345 #define Cns_MAX_BYTES_IP Cns_MAX_CHARS_IP // 15 -#define Cns_MAX_CHARS_DATE (4 + 1 + 2 + 1 + 2) -#define Cns_MAX_BYTES_DATE Cns_MAX_CHARS_DATE +#define Cns_MAX_CHARS_DATE (16 - 1) // 15 +#define Cns_MAX_BYTES_DATE ((Cns_MAX_CHARS_DATE + 1) * Str_MAX_BYTES_PER_CHAR - 1) // 255 #define Cns_MAX_CHARS_EMAIL_ADDRESS (256 - 1) // 255 #define Cns_MAX_BYTES_EMAIL_ADDRESS Cns_MAX_CHARS_EMAIL_ADDRESS // 255 diff --git a/swad_date.c b/swad_date.c index 6448d2c4..b6ab418a 100644 --- a/swad_date.c +++ b/swad_date.c @@ -380,15 +380,36 @@ struct tm *Dat_GetLocalTimeFromClock (const time_t *timep) /********* Convert a struct with Day, Month and Year to a date string ********/ /*****************************************************************************/ -void Dat_ConvDateToDateStr (struct Date *Date,char *DateStr) +void Dat_ConvDateToDateStr (struct Date *Date,char StrDate[Cns_MAX_BYTES_DATE + 1]) { + extern const char *Txt_MONTHS_SMALL_SHORT[12]; + if (Date->Day == 0 || Date->Month == 0 || Date->Year == 0) - DateStr[0] = '\0'; + StrDate[0] = '\0'; else - sprintf (DateStr,"%04u-%02u-%02u", - Date->Year,Date->Month,Date->Day); + switch (Gbl.Prefs.DateFormat) + { + case Dat_FORMAT_YYYY_MM_DD: + sprintf (StrDate,"%04u-%02u-%02u", + Date->Year, + Date->Month, + Date->Day); + break; + case Dat_FORMAT_DD_MONTH_YYYY: + sprintf (StrDate,"%u %s %04u", + Date->Day, + Txt_MONTHS_SMALL_SHORT[Date->Month - 1], + Date->Year); + break; + case Dat_FORMAT_MONTH_DD_YYYY: + sprintf (StrDate,"%s %u, %04u", + Txt_MONTHS_SMALL_SHORT[Date->Month - 1], + Date->Day, + Date->Year); + break; + } } /*****************************************************************************/ diff --git a/swad_date.h b/swad_date.h index 8bf68bb5..67a877e8 100644 --- a/swad_date.h +++ b/swad_date.h @@ -31,6 +31,8 @@ #include // For FILE * #include +#include "swad_constant.h" + /*****************************************************************************/ /***************************** Public constants ******************************/ /*****************************************************************************/ @@ -130,7 +132,7 @@ bool Dat_GetDateFromYYYYMMDD (struct Date *Date,const char *YYYYMMDDString); void Dat_ShowClientLocalTime (void); struct tm *Dat_GetLocalTimeFromClock (const time_t *timep); -void Dat_ConvDateToDateStr (struct Date *Date,char *DateStr); +void Dat_ConvDateToDateStr (struct Date *Date,char StrDate[Cns_MAX_BYTES_DATE + 1]); void Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (bool SetHMS000000To235959); void Dat_PutFormStartEndClientLocalDateTimes (time_t TimeUTC[2], diff --git a/swad_exam.c b/swad_exam.c index 30709e1c..5b0a17a9 100644 --- a/swad_exam.c +++ b/swad_exam.c @@ -1026,7 +1026,9 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa const char *StyleNormal = "CONV"; struct Instit Ins; char StrExamDate[Cns_MAX_BYTES_DATE + 1]; - unsigned Year,Hour,Minute; + unsigned Year; + unsigned Hour; + unsigned Minute; const char *ClassExaAnnouncement[Exa_NUM_VIEWS][Exa_NUM_STATUS] = { { // Exa_NORMAL_VIEW @@ -1211,7 +1213,7 @@ static void Exa_ShowExamAnnouncement (Exa_TypeViewExamAnnouncement_t TypeViewExa { fprintf (Gbl.F.Out,""); Dat_WriteFormDate (Gbl.ExamAnns.ExaDat.ExamDate.Year < Gbl.Now.Date.Year ? Gbl.ExamAnns.ExaDat.ExamDate.Year : - Gbl.Now.Date.Year, + Gbl.Now.Date.Year, Gbl.Now.Date.Year + 1,"Exam", &(Gbl.ExamAnns.ExaDat.ExamDate), false,false); @@ -1596,6 +1598,7 @@ void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Ntf_MAX_BYTES_SUM { extern const char *Txt_hours_ABBREVIATION; char CrsNameAndDate[Hie_MAX_BYTES_FULL_NAME + (2 + Cns_MAX_BYTES_DATE + 6) + 1]; + char StrExamDate[Cns_MAX_BYTES_DATE + 1]; /***** Initializations *****/ Gbl.ExamAnns.ExaDat.ExaCod = ExaCod; @@ -1613,11 +1616,10 @@ void Exa_GetSummaryAndContentExamAnnouncement (char SummaryStr[Ntf_MAX_BYTES_SUM /***** Summary *****/ /* Name of the course and date of exam */ - sprintf (CrsNameAndDate,"%s, %04u-%02u-%02u %2u:%02u", + Dat_ConvDateToDateStr (&Gbl.ExamAnns.ExaDat.ExamDate,StrExamDate); + sprintf (CrsNameAndDate,"%s, %s, %2u:%02u", Gbl.ExamAnns.ExaDat.CrsFullName, - Gbl.ExamAnns.ExaDat.ExamDate.Year, - Gbl.ExamAnns.ExaDat.ExamDate.Month, - Gbl.ExamAnns.ExaDat.ExamDate.Day, + StrExamDate, Gbl.ExamAnns.ExaDat.StartTime.Hour, Gbl.ExamAnns.ExaDat.StartTime.Minute); Str_Copy (SummaryStr,CrsNameAndDate, diff --git a/swad_holiday.c b/swad_holiday.c index 4349b181..aaa8865d 100644 --- a/swad_holiday.c +++ b/swad_holiday.c @@ -88,6 +88,7 @@ void Hld_SeeHolidays (void) extern const char *Txt_New_holiday; Hld_Order_t Order; unsigned NumHld; + char StrDate[Cns_MAX_BYTES_DATE + 1]; if (Gbl.CurrentIns.Ins.InsCod > 0) { @@ -145,12 +146,11 @@ void Hld_SeeHolidays (void) "", Gbl.Hlds.Lst[NumHld].PlcCod <= 0 ? Txt_All_places : Gbl.Hlds.Lst[NumHld].PlaceFullName); + Dat_ConvDateToDateStr (&Gbl.Hlds.Lst[NumHld].StartDate,StrDate); fprintf (Gbl.F.Out,"" - " %04u-%02u-%02u" + " %s" "", - Gbl.Hlds.Lst[NumHld].StartDate.Year, - Gbl.Hlds.Lst[NumHld].StartDate.Month, - Gbl.Hlds.Lst[NumHld].StartDate.Day); + StrDate); fprintf (Gbl.F.Out,"" " "); switch (Gbl.Hlds.Lst[NumHld].HldTyp) @@ -158,10 +158,8 @@ void Hld_SeeHolidays (void) case Hld_HOLIDAY: break; case Hld_NON_SCHOOL_PERIOD: - fprintf (Gbl.F.Out,"%04u-%02u-%02u", - Gbl.Hlds.Lst[NumHld].EndDate.Year, - Gbl.Hlds.Lst[NumHld].EndDate.Month, - Gbl.Hlds.Lst[NumHld].EndDate.Day); + Dat_ConvDateToDateStr (&Gbl.Hlds.Lst[NumHld].EndDate,StrDate); + fprintf (Gbl.F.Out,"%s",StrDate); break; } fprintf (Gbl.F.Out,"" @@ -792,7 +790,7 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) struct Date NewDate; struct Date *PtrDate = NULL; // Initialized to avoid warning const char *StrStartOrEndDate = NULL; // Initialized to avoid warning - char StrDate[11]; + char StrDate[Cns_MAX_BYTES_DATE + 1]; Hld = &Gbl.Hlds.EditingHld; @@ -848,8 +846,7 @@ static void Hld_ChangeDate (Hld_StartOrEndDate_t StartOrEndDate) /***** Write message to show the change made *****/ Gbl.AlertType = Lay_SUCCESS; - sprintf (StrDate,"%04u-%02u-%02u", - NewDate.Year,NewDate.Month,NewDate.Day); // Change format depending on location + Dat_ConvDateToDateStr (&NewDate,StrDate); sprintf (Gbl.Message,Txt_The_date_of_the_holiday_X_has_changed_to_Y, Hld->Name,StrDate); } diff --git a/swad_statistic.c b/swad_statistic.c index 246110a9..0a9a8bbc 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -1981,6 +1981,7 @@ static void Sta_ShowNumHitsPerDays (unsigned long NumRows, int NumDayWeek; struct Sta_Hits Hits; MYSQL_ROW row; + char StrDate[Cns_MAX_BYTES_DATE + 1]; /***** Initialize LastDate *****/ Dat_AssignDate (&LastDate,&Gbl.DateRange.DateEnd.Date); @@ -2030,13 +2031,14 @@ static void Sta_ShowNumHitsPerDays (unsigned long NumRows, NumDayWeek = Dat_GetDayOfWeek (Date.Year,Date.Month,Date.Day); /* Write the date */ + Dat_ConvDateToDateStr (&Date,StrDate); fprintf (Gbl.F.Out,"" "" - "%04u-%02u-%02u " + "%s " "", NumDayWeek == 6 ? "LOG_R" : "LOG", - Date.Year,Date.Month,Date.Day); + StrDate); /* Write the day of the week */ fprintf (Gbl.F.Out,"" @@ -2045,6 +2047,7 @@ static void Sta_ShowNumHitsPerDays (unsigned long NumRows, NumDayWeek == 6 ? "LOG_R" : "LOG", Txt_DAYS_SMALL[NumDayWeek]); + /* Draw bar proportional to number of pages generated */ Sta_DrawBarNumHits (NumDayWeek == 6 ? 'r' : 'c', @@ -2068,13 +2071,14 @@ static void Sta_ShowNumHitsPerDays (unsigned long NumRows, NumDayWeek = Dat_GetDayOfWeek (Date.Year,Date.Month,Date.Day); /* Write the date */ + Dat_ConvDateToDateStr (&Date,StrDate); fprintf (Gbl.F.Out,"" "" - "%04u-%02u-%02u " + "%s " "", NumDayWeek == 6 ? "LOG_R" : "LOG", - Date.Year,Date.Month,Date.Day); + StrDate); /* Write the day of the week */ fprintf (Gbl.F.Out,"" @@ -2126,6 +2130,7 @@ static void Sta_ShowDistrAccessesPerDaysAndHour (unsigned long NumRows,MYSQL_RES float NumAccPerHour[24]; float NumAccPerHourZero[24]; MYSQL_ROW row; + char StrDate[Cns_MAX_BYTES_DATE + 1]; /***** Get selected color type *****/ SelectedColorType = Sta_GetStatColorType (); @@ -2254,13 +2259,14 @@ static void Sta_ShowDistrAccessesPerDaysAndHour (unsigned long NumRows,MYSQL_RES NumDayWeek = Dat_GetDayOfWeek (Date.Year,Date.Month,Date.Day); /* Write the date */ + Dat_ConvDateToDateStr (&Date,StrDate); fprintf (Gbl.F.Out,"" "" - "%04u-%02u-%02u " + "%s " "", NumDayWeek == 6 ? "LOG_R" : "LOG", - Date.Year,Date.Month,Date.Day); + StrDate); /* Write the day of the week */ fprintf (Gbl.F.Out,"" @@ -2304,13 +2310,14 @@ static void Sta_ShowDistrAccessesPerDaysAndHour (unsigned long NumRows,MYSQL_RES NumDayWeek = Dat_GetDayOfWeek (Date.Year,Date.Month,Date.Day); /* Write the date */ + Dat_ConvDateToDateStr (&Date,StrDate); fprintf (Gbl.F.Out,"" "" - "%04u-%02u-%02u " + "%s " "", NumDayWeek == 6 ? "LOG_R" : "LOG", - Date.Year,Date.Month,Date.Day); + StrDate); /* Write the day of the week */ fprintf (Gbl.F.Out,"" @@ -2342,13 +2349,14 @@ static void Sta_ShowDistrAccessesPerDaysAndHour (unsigned long NumRows,MYSQL_RES NumDayWeek = Dat_GetDayOfWeek (Date.Year,Date.Month,Date.Day); /* Write the date */ + Dat_ConvDateToDateStr (&Date,StrDate); fprintf (Gbl.F.Out,"" "" - "%04u-%02u-%02u " + "%s " "", NumDayWeek == 6 ? "LOG_R" : "LOG", - Date.Year,Date.Month,Date.Day); + StrDate); /* Write the day of the week */ fprintf (Gbl.F.Out,""