diff --git a/swad_changelog.h b/swad_changelog.h
index 5c01048de..68ec0d3bc 100644
--- a/swad_changelog.h
+++ b/swad_changelog.h
@@ -108,11 +108,12 @@
/****************************** Public constants *****************************/
/*****************************************************************************/
-#define Log_PLATFORM_VERSION "SWAD 15.20.2 (2015/10/24)"
+#define Log_PLATFORM_VERSION "SWAD 15.21 (2015/10/25)"
// 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.21: Oct 25, 2015 New forms to enter range of date-times in statistic and test. Not finished. (186549 lines)
Version 15.20.2: Oct 24, 2015 Code refactoring related to date-times forms. (186294 lines)
Version 15.20.1: Oct 24, 2015 Detailed clics are displayed in client local date-time. (186333 lines)
Version 15.20: Oct 24, 2015 Date-times in notifications, messages and forums are displayed in client local date-time. (186334 lines)
diff --git a/swad_date.c b/swad_date.c
index 3ce5c566c..18ec0cf95 100644
--- a/swad_date.c
+++ b/swad_date.c
@@ -63,10 +63,14 @@ const unsigned Dat_NumDaysMonth[1+12] =
/***************************** Private prototypes ****************************/
/*****************************************************************************/
-static void Dat_WriteFormClientLocalDateTime (const char *Id,
- time_t TimeUTC,
- unsigned FirstYear,unsigned LastYear,
- bool SubmitFormOnChange,bool Disabled);
+static void Dat_WriteFormClientLocalDateTimeFromTimeUTC (const char *Id,
+ time_t TimeUTC,
+ unsigned FirstYear,unsigned LastYear,
+ bool SubmitFormOnChange,bool Disabled);
+static void Dat_WriteFormClientLocalDateTimeFromYMDhms (const char *Id,
+ struct Date *DateSelected,
+ unsigned FirstYear,unsigned LastYear,
+ bool SubmitFormOnChange,bool Disabled);
/*****************************************************************************/
/***************************** Get current time ******************************/
@@ -271,6 +275,69 @@ void Dat_WriteFormIniEndDates (void)
"");
}
+/*****************************************************************************/
+/*************** Show forms to enter initial and ending dates ****************/
+/*****************************************************************************/
+
+void Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (void)
+ {
+ extern const char *The_ClassForm[The_NUM_THEMES];
+ extern const char *Txt_Start_date;
+ extern const char *Txt_End_date;
+ extern const char *Txt_Yesterday;
+ extern const char *Txt_Today;
+
+ /***** Start date-time *****/
+ fprintf (Gbl.F.Out,"
"
+ ""
+ "%s:"
+ " | "
+ "",
+ The_ClassForm[Gbl.Prefs.Theme],
+ Txt_Start_date);
+ /* Date-time */
+ Dat_WriteFormClientLocalDateTimeFromYMDhms ("Start",
+ &Gbl.DateRange.DateIni,
+ Cfg_LOG_START_YEAR,
+ Gbl.Now.Date.Year,
+ false,false);
+
+ /***** "Yesterday" and "Today" buttons *****/
+ fprintf (Gbl.F.Out," | "
+ ""
+ ""
+ ""
+ " | "
+ "
",
+ Txt_Yesterday,
+ Gbl.Yesterday.Day,
+ Gbl.Yesterday.Month,
+ Gbl.Yesterday.Year - Cfg_LOG_START_YEAR + 1,
+ Txt_Today,
+ Gbl.Now.Date.Day,
+ Gbl.Now.Date.Month,
+ Gbl.Now.Date.Year - Cfg_LOG_START_YEAR + 1);
+
+ /***** End date-time *****/
+ fprintf (Gbl.F.Out,""
+ ""
+ "%s:"
+ " | "
+ "",
+ The_ClassForm[Gbl.Prefs.Theme],
+ Txt_End_date);
+ /* Date-time */
+ Dat_WriteFormClientLocalDateTimeFromYMDhms ("End",
+ &Gbl.DateRange.DateEnd,
+ Cfg_LOG_START_YEAR,
+ Gbl.Now.Date.Year,
+ false,false);
+
+ fprintf (Gbl.F.Out," | "
+ "
");
+ }
/*****************************************************************************/
/************* Show forms to enter initial and ending date-times *************/
@@ -309,11 +376,11 @@ void Dat_PutFormStartEndClientLocalDateTimes (time_t TimeUTC[2])
Dates[StartOrEndTime]);
/* Date-time */
- Dat_WriteFormClientLocalDateTime (Id[StartOrEndTime],
- TimeUTC[StartOrEndTime],
- Gbl.Now.Date.Year - 1,
- Gbl.Now.Date.Year + 1,
- false,false);
+ Dat_WriteFormClientLocalDateTimeFromTimeUTC (Id[StartOrEndTime],
+ TimeUTC[StartOrEndTime],
+ Gbl.Now.Date.Year - 1,
+ Gbl.Now.Date.Year + 1,
+ false,false);
fprintf (Gbl.F.Out,""
""
@@ -327,10 +394,10 @@ void Dat_PutFormStartEndClientLocalDateTimes (time_t TimeUTC[2])
/************************* Show a form to enter a date ***********************/
/*****************************************************************************/
-static void Dat_WriteFormClientLocalDateTime (const char *Id,
- time_t TimeUTC,
- unsigned FirstYear,unsigned LastYear,
- bool SubmitFormOnChange,bool Disabled)
+static void Dat_WriteFormClientLocalDateTimeFromTimeUTC (const char *Id,
+ time_t TimeUTC,
+ unsigned FirstYear,unsigned LastYear,
+ bool SubmitFormOnChange,bool Disabled)
{
extern const char *Txt_MONTHS_SMALL[12];
unsigned Day;
@@ -384,7 +451,7 @@ static void Dat_WriteFormClientLocalDateTime (const char *Id,
Month <= 12;
Month++)
fprintf (Gbl.F.Out,"",
- Month,Txt_MONTHS_SMALL[Month-1]);
+ Month,Txt_MONTHS_SMALL[Month - 1]);
fprintf (Gbl.F.Out,""
"");
@@ -479,12 +546,206 @@ static void Dat_WriteFormClientLocalDateTime (const char *Id,
/***** Script to set selectors to local date and time from UTC time *****/
fprintf (Gbl.F.Out,"",
Id,(long) TimeUTC,Id);
}
+
+/*****************************************************************************/
+/************************* Show a form to enter a date ***********************/
+/*****************************************************************************/
+
+static void Dat_WriteFormClientLocalDateTimeFromYMDhms (const char *Id,
+ struct Date *DateSelected,
+ unsigned FirstYear,unsigned LastYear,
+ bool SubmitFormOnChange,bool Disabled)
+ {
+ extern const char *Txt_MONTHS_SMALL[12];
+ unsigned Day;
+ unsigned Month;
+ unsigned Year;
+ unsigned Hour;
+ unsigned Minute;
+ unsigned Second;
+ unsigned NumDaysSelectedMonth = (DateSelected->Month == 0) ? 31 :
+ ((DateSelected->Month == 2) ? Dat_GetNumDaysFebruary (DateSelected->Year) :
+ Dat_NumDaysMonth[DateSelected->Month]);
+ struct Time TimeSelected; // Put hour, minute and second in struct Date
+ TimeSelected.Hour = 0;
+ TimeSelected.Minute = 0;
+ TimeSelected.Second = 0;
+
+ /***** Start table *****/
+ fprintf (Gbl.F.Out,""
+ "");
+
+ /***** Year *****/
+ fprintf (Gbl.F.Out,""
+ ""
+ " | ");
+
+ /***** Month *****/
+ fprintf (Gbl.F.Out,""
+ ""
+ " | ");
+
+ /***** Day *****/
+ fprintf (Gbl.F.Out,""
+ ""
+ " | ");
+
+ /***** Hour *****/
+ fprintf (Gbl.F.Out,", "
+ ""
+ " | ");
+
+ /***** Minute *****/
+ fprintf (Gbl.F.Out,""
+ ""
+ " | ");
+
+ /***** Second *****/
+ fprintf (Gbl.F.Out,""
+ ""
+ " | ");
+
+ /***** End table *****/
+ fprintf (Gbl.F.Out,"
"
+ "
");
+
+ /***** Hidden field with UTC time (seconds since 1970) used to send time *****/
+ fprintf (Gbl.F.Out,"",
+ Id,Id);
+
+ /***** Script to set UTC time from selectors with local date and time *****/
+ fprintf (Gbl.F.Out,"",
+ Id,Id);
+ }
+
/*****************************************************************************/
/***************** Get an hour-minute time from a form ***********************/
/*****************************************************************************/
@@ -569,7 +830,7 @@ void Dat_WriteFormDate (unsigned FirstYear,unsigned LastYear,
fprintf (Gbl.F.Out,"",Txt_MONTHS_SMALL[Month-1]);
+ fprintf (Gbl.F.Out,">%s",Txt_MONTHS_SMALL[Month - 1]);
}
/***** Year *****/
@@ -717,6 +978,7 @@ void Dat_GetIniEndDatesFromForm (void)
&Gbl.DateRange.DateIni.Day,
&Gbl.DateRange.DateIni.Month,
&Gbl.DateRange.DateIni.Year);
+ // TODO: Get hour, minute and second
if (Gbl.DateRange.DateIni.Day == 0 ||
Gbl.DateRange.DateIni.Month == 0 ||
Gbl.DateRange.DateIni.Year == 0)
@@ -725,12 +987,14 @@ void Dat_GetIniEndDatesFromForm (void)
Gbl.DateRange.DateIni.Month = Cfg_LOG_START_MONTH;
Gbl.DateRange.DateIni.Year = Cfg_LOG_START_YEAR;
}
+ Gbl.DateRange.TimeUTC[0] = Dat_GetTimeUTCFromForm ("StartTimeUTC");
/***** Get end date *****/
Dat_GetDateFromForm ("EndDay","EndMonth","EndYear",
&Gbl.DateRange.DateEnd.Day,
&Gbl.DateRange.DateEnd.Month,
&Gbl.DateRange.DateEnd.Year);
+ // TODO: Get hour, minute and second
if (Gbl.DateRange.DateEnd.Day == 0 ||
Gbl.DateRange.DateEnd.Month == 0 ||
Gbl.DateRange.DateEnd.Year == 0)
@@ -739,6 +1003,7 @@ void Dat_GetIniEndDatesFromForm (void)
Gbl.DateRange.DateEnd.Month = Gbl.Now.Date.Month;
Gbl.DateRange.DateEnd.Year = Gbl.Now.Date.Year;
}
+ Gbl.DateRange.TimeUTC[1] = Dat_GetTimeUTCFromForm ("EndTimeUTC");
}
/*****************************************************************************/
diff --git a/swad_date.h b/swad_date.h
index 9ba02af28..d770ed921 100644
--- a/swad_date.h
+++ b/swad_date.h
@@ -78,6 +78,7 @@ void Dat_GetLocalTimeFromClock (const time_t *clock);
void Dat_ConvDateToDateStr (struct Date *Date,char *DateStr);
void Dat_WriteFormIniEndDates (void);
+void Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday (void);
void Dat_PutFormStartEndClientLocalDateTimes (time_t TimeUTC[2]);
time_t Dat_GetTimeUTCFromForm (const char *ParamName);
diff --git a/swad_global.h b/swad_global.h
index 702d97177..15266c58e 100644
--- a/swad_global.h
+++ b/swad_global.h
@@ -642,8 +642,9 @@ struct Globals
} Test;
struct
{
- struct Date DateIni;
- struct Date DateEnd;
+ struct Date DateIni; // TODO: Remove in future versions
+ struct Date DateEnd; // TODO: Remove in future versions
+ time_t TimeUTC[2];
} DateRange;
struct
{
diff --git a/swad_statistic.c b/swad_statistic.c
index 96f86eaa2..7bed92e8e 100644
--- a/swad_statistic.c
+++ b/swad_statistic.c
@@ -506,7 +506,8 @@ void Sta_AskShowCrsHits (void)
"");
/***** Initial and final dates of the search *****/
- Dat_WriteFormIniEndDates ();
+ // Dat_WriteFormIniEndDates ();
+ Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday ();
/***** Selection of action *****/
Sta_WriteSelectorAction ();
@@ -643,7 +644,8 @@ void Sta_AskShowGblHits (void)
Lay_StartRoundFrameTable (NULL,2,Txt_Statistics_of_all_visits);
/***** Start and end dates for the search *****/
- Dat_WriteFormIniEndDates ();
+ // Dat_WriteFormIniEndDates ();
+ Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday ();
/***** Users' roles whose accesses we want to see *****/
fprintf (Gbl.F.Out,""
diff --git a/swad_test.c b/swad_test.c
index 6700e10e3..c2c803d3f 100644
--- a/swad_test.c
+++ b/swad_test.c
@@ -1120,7 +1120,8 @@ void Tst_ShowFormAskEditTsts (void)
/***** Starting and ending dates in the search *****/
fprintf (Gbl.F.Out,"");
- Dat_WriteFormIniEndDates ();
+ // Dat_WriteFormIniEndDates ();
+ Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday ();
fprintf (Gbl.F.Out,"
"
"");
@@ -5948,7 +5949,8 @@ void Tst_SelUsrsToSeeUsrsTstExams (void)
"
");
/***** Starting and ending dates in the search *****/
- Dat_WriteFormIniEndDates ();
+ // Dat_WriteFormIniEndDates ();
+ Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday ();
fprintf (Gbl.F.Out,"");
@@ -5990,7 +5992,8 @@ void Tst_SelDatesToSeeMyTstExams (void)
/***** Starting and ending dates in the search *****/
Lay_StartRoundFrameTable (NULL,2,Txt_Exams);
- Dat_WriteFormIniEndDates ();
+ // Dat_WriteFormIniEndDates ();
+ Dat_PutFormStartEndClientLocalDateTimesWithYesterdayToday ();
/***** Send button and end frame *****/
Lay_EndRoundFrameTableWithButton (Lay_CONFIRM_BUTTON,Txt_See_exams);