From b4075bd63ff77607ad56c9f0f26fdecd5fb5762a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ca=C3=B1as=20Vargas?= Date: Tue, 27 Oct 2015 22:59:49 +0100 Subject: [PATCH] Version 15.26 --- js/swad.js | 8 ++++++++ swad_changelog.h | 3 ++- swad_date.c | 44 +++++++++++++++++++++++++++++++++++++++++++ swad_date.h | 3 +++ swad_statistic.c | 49 +++++++++++++++++++++++++++++++++--------------- swad_text.c | 39 -------------------------------------- 6 files changed, 91 insertions(+), 55 deletions(-) diff --git a/js/swad.js b/js/swad.js index e9f35d8ea..60dd30172 100644 --- a/js/swad.js +++ b/js/swad.js @@ -193,6 +193,14 @@ function setUTCFromLocalDateTimeForm(id) { } } +// Set form param with time difference between UTC time and client local time, in minutes +function setTZ(id) { + var FormTZ = document.getElementById(id); + var d = new (Date); + + FormTZ.value = d.getTimezoneOffset(); +} + // Adjust a date form correcting days in the month function adjustDateForm (id) { var FormYea = document.getElementById(id+'Year' ); diff --git a/swad_changelog.h b/swad_changelog.h index 327b40d72..7a4b41a76 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -108,11 +108,12 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 15.25.4 (2015/10/27)" +#define Log_PLATFORM_VERSION "SWAD 15.26 (2015/10/27)" // 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 15.26: Oct 27, 2015 Statistics are computed properly for clients with time-zones different to that of the server. (186278 lines) Version 15.25.4: Oct 27, 2015 Day and month are displayed in clock. (186251 lines) Version 15.25.3: Oct 27, 2015 Statistics computed using time UTC. (186225 lines) Version 15.25.2: Oct 26, 2015 Changes related to date-times. (186247 lines) diff --git a/swad_date.c b/swad_date.c index 85168b826..2d3e536cf 100644 --- a/swad_date.c +++ b/swad_date.c @@ -467,6 +467,50 @@ time_t Dat_GetTimeUTCFromForm (const char *ParamName) return Dat_GetUNIXTimeFromStr (LongStr); } +/*****************************************************************************/ +/**************** Put a hidden param with time difference ********************/ +/**************** between UTC time and client local time, ********************/ +/**************** in minutes ********************/ +/*****************************************************************************/ + +void Dat_PutHiddenParClientTZDiff (void) + { + fprintf (Gbl.F.Out,"" + ""); + } + +/*****************************************************************************/ +/**************** Get string with time difference ********************/ +/**************** between UTC time and client local time, ********************/ +/**************** in +hh:mm or -hh:mm format ********************/ +/*****************************************************************************/ +// ClientTZStr must have space for strings in +hh:mm format (6 characters + \0) + +void Dat_GetClientTZDiff (char *ClientTZStr) + { + char IntStr[1+10+1]; + int ClientTZDiff; // Time difference between UTC time and client local time, in minutes + + /***** Get client time zone *****/ + Par_GetParToText ("ClientTZDiff",IntStr,1+10); + if (sscanf (IntStr,"%d",&ClientTZDiff) != 1) + ClientTZDiff = 0; + + /***** Convert from minutes to +hh:mm or -hh:mm *****/ + if (ClientTZDiff >= 0) + sprintf (ClientTZStr,"+%02u:%02u", + (unsigned) ClientTZDiff / 60, + (unsigned) ClientTZDiff % 60); + else + sprintf (ClientTZStr,"-%02u:%02u", + (unsigned) (-ClientTZDiff) / 60, + (unsigned) (-ClientTZDiff) % 60); + } + /*****************************************************************************/ /************************* Show a form to enter a date ***********************/ /*****************************************************************************/ diff --git a/swad_date.h b/swad_date.h index 5803b23fa..f41e865bc 100644 --- a/swad_date.h +++ b/swad_date.h @@ -86,6 +86,9 @@ void Dat_WriteFormClientLocalDateTimeFromTimeUTC (const char *Id, bool SubmitFormOnChange); time_t Dat_GetTimeUTCFromForm (const char *ParamName); +void Dat_PutHiddenParClientTZDiff (void); +void Dat_GetClientTZDiff (char *ClientTZStr); + void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear, const char *Id, struct Date *DateSelected, diff --git a/swad_statistic.c b/swad_statistic.c index c94067476..fdeffbc56 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -445,7 +445,6 @@ void Sta_AskShowCrsHits (void) extern const char *Txt_distributed_by; extern const char *Txt_STAT_CLICKS_GROUPED_BY[Sta_NUM_CLICKS_GROUPED_BY]; extern const char *Txt_results_per_page; - extern const char *Txt_The_statistics_marked_with_; extern const char *Txt_Show_hits; extern const char *Txt_No_teachers_or_students_found; static unsigned long RowsPerPage[] = {10,20,30,40,50,100,500,1000,5000,10000,50000,100000}; @@ -579,9 +578,8 @@ void Sta_AskShowCrsHits (void) "" ""); - /***** Warning *****/ - fprintf (Gbl.F.Out,"

%s

", - Txt_The_statistics_marked_with_); + /***** Hidden param used to get client time zone *****/ + Dat_PutHiddenParClientTZDiff (); /***** Send button *****/ Lay_PutConfirmButton (Txt_Show_hits); @@ -621,7 +619,6 @@ void Sta_AskShowGblHits (void) extern const char *Txt_Show; extern const char *Txt_distributed_by; extern const char *Txt_STAT_CLICKS_GROUPED_BY[Sta_NUM_CLICKS_GROUPED_BY]; - extern const char *Txt_The_statistics_marked_with_; extern const char *Txt_Show_hits; Sta_Role_t RoleStat; Sta_ClicksGroupedBy_t ClicksGroupedBy; @@ -729,9 +726,8 @@ void Sta_AskShowGblHits (void) "" ""); - /***** Warning *****/ - fprintf (Gbl.F.Out,"

%s

", - Txt_The_statistics_marked_with_); + /***** Hidden param used to get client time zone *****/ + Dat_PutHiddenParClientTZDiff (); /***** Send button *****/ Lay_PutConfirmButton (Txt_Show_hits); @@ -857,6 +853,8 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) const char *LogTable; Sta_ClicksDetailedOrGrouped_t DetailedOrGrouped = Sta_CLICKS_GROUPED; struct UsrData UsrDat; + char ClientTZStr[1+2+1+2+1]; // Time difference between UTC time and client local time, + // in +hh:mm or -hh:mm format unsigned NumUsr = 0; const char *Ptr; char StrRole[256]; @@ -869,6 +867,9 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) /***** Get initial and ending dates *****/ Dat_GetIniEndDatesFromForm (); + /***** Get client time zone *****/ + Dat_GetClientTZDiff (ClientTZStr); + /***** Set table where to find depending on initial date *****/ // If initial day is older than current day minus Cfg_DAYS_IN_RECENT_LOG, then use recent log table, else use historic log table */ LogTable = (Dat_GetNumDaysBetweenDates (&Gbl.DateRange.DateIni.Date,&Gbl.Now.Date) <= Cfg_DAYS_IN_RECENT_LOG) ? "log_recent" : @@ -1028,14 +1029,20 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) break; case Sta_CLICKS_CRS_PER_DAYS: case Sta_CLICKS_GBL_PER_DAYS: - sprintf (Query,"SELECT SQL_NO_CACHE DATE_FORMAT(ClickTime,'%%Y%%m%%d') AS Day,%s FROM %s", + sprintf (Query,"SELECT SQL_NO_CACHE " + "DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%Y%%m%%d') AS Day," + "%s FROM %s", + ClientTZStr, StrQueryCountType,LogTable); break; case Sta_CLICKS_CRS_PER_DAYS_AND_HOUR: case Sta_CLICKS_GBL_PER_DAYS_AND_HOUR: sprintf (Query,"SELECT SQL_NO_CACHE " - "DATE_FORMAT(ClickTime,'%%Y%%m%%d') AS Day," - "DATE_FORMAT(ClickTime,'%%H') AS Hour,%s FROM %s", + "DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%Y%%m%%d') AS Day," + "DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%H') AS Hour," + "%s FROM %s", + ClientTZStr, + ClientTZStr, StrQueryCountType,LogTable); break; case Sta_CLICKS_CRS_PER_WEEKS: @@ -1043,22 +1050,34 @@ static void Sta_ShowHits (Sta_GlobalOrCourseAccesses_t GlobalOrCourse) /* With %v the weeks always are counted from monday to sunday. 01/01/2006 was sunday => it's counted in the week 52 of 2005, that goes from 26/12/2005 (monday) to 01/01/2006 (sunday). The week 1 of 2006 goes from 02/01/2006 (monday) to 08/01/2006 (sunday) */ - sprintf (Query,"SELECT SQL_NO_CACHE DATE_FORMAT(ClickTime,'%%x%%v') AS Week,%s FROM %s", + sprintf (Query,"SELECT SQL_NO_CACHE " + "DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%x%%v') AS Week," + "%s FROM %s", + ClientTZStr, StrQueryCountType,LogTable); break; case Sta_CLICKS_CRS_PER_MONTHS: case Sta_CLICKS_GBL_PER_MONTHS: - sprintf (Query,"SELECT SQL_NO_CACHE DATE_FORMAT(ClickTime,'%%Y%%m') AS Month,%s FROM %s", + sprintf (Query,"SELECT SQL_NO_CACHE " + "DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%Y%%m') AS Month," + "%s FROM %s", + ClientTZStr, StrQueryCountType,LogTable); break; case Sta_CLICKS_CRS_PER_HOUR: case Sta_CLICKS_GBL_PER_HOUR: - sprintf (Query,"SELECT SQL_NO_CACHE DATE_FORMAT(ClickTime,'%%H') AS Hour,%s FROM %s", + sprintf (Query,"SELECT SQL_NO_CACHE " + "DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%H') AS Hour," + "%s FROM %s", + ClientTZStr, StrQueryCountType,LogTable); break; case Sta_CLICKS_CRS_PER_MINUTE: case Sta_CLICKS_GBL_PER_MINUTE: - sprintf (Query,"SELECT SQL_NO_CACHE DATE_FORMAT(ClickTime,'%%H%%i') AS Minute,%s FROM %s", + sprintf (Query,"SELECT SQL_NO_CACHE " + "DATE_FORMAT(CONVERT_TZ(ClickTime,@@session.time_zone,'%s'),'%%H%%i') AS Minute," + "%s FROM %s", + ClientTZStr, StrQueryCountType,LogTable); break; case Sta_CLICKS_CRS_PER_ACTION: diff --git a/swad_text.c b/swad_text.c index 19d7e3305..f8c66df2d 100644 --- a/swad_text.c +++ b/swad_text.c @@ -42039,45 +42039,6 @@ const char *Txt_The_session_has_expired_due_to_inactivity = // Expired due to ti "A sessão expirou devido à inatividade."; #endif -const char *Txt_The_statistics_marked_with_ = -#if L==0 - "Les estadístiques marcades amb *" - " es calculen segons l'hora del servidor," - " que pot no coincidir amb la seva hora local."; -#elif L==1 - "Die mit * gekennzeichneten Statistiken" - " werden nach der Serverzeit," - " die nicht Ihrer lokalen Zeit entsprechen berechnet."; -#elif L==2 - "The statistics marked with *" - " are calculated according to the server time," - " which may not match your local time."; -#elif L==3 - "Las estadísticas marcadas con *" - " se calculan según la hora del servidor," - " que puede no coincidir con su hora local."; -#elif L==4 - "Les statistiques marqués d'une *" - " sont calculés selon l'heure du serveur," - " qui peut ne pas correspondre à votre heure locale."; -#elif L==5 - "Las estadísticas marcadas con *" - " se calculan según la hora del servidor," - " que puede no coincidir con su hora local."; // Okoteve traducción -#elif L==6 - "Le statistiche contrassegnati con *" - " sono calcolati secondo l'ora del server," - " che non può corrispondere l'ora locale."; -#elif L==7 - "Statystyki oznaczone *" - " są obliczane według czasu serwera," - " które mogą nie odpowiadać czasu lokalnego."; -#elif L==8 - "As estatísticas marcados com *" - " são calculados de acordo com a hora do servidor," - " que pode não coincidir com a hora local."; -#endif - const char *Txt_The_status_of_the_centre_X_has_changed = // Warning: it is very important to include %s in the following sentences #if L==0 "El estado del centro %s ha cambiado."; // Necessita traduccio