diff --git a/css/swad16.202.css b/css/swad16.205.css similarity index 99% rename from css/swad16.202.css rename to css/swad16.205.css index 2bf6e6c1b..4f360a24d 100644 --- a/css/swad16.202.css +++ b/css/swad16.205.css @@ -1215,6 +1215,7 @@ a:hover /* Default ==> underlined */ color:#4D88A1; font-size:9pt; white-space:nowrap; + text-transform:uppercase; } .DAY_WRK_HEAD { diff --git a/js/swad16.181.js b/js/swad16.205.js similarity index 97% rename from js/swad16.181.js rename to js/swad16.205.js index 510c40cdf..535aabcb0 100644 --- a/js/swad16.181.js +++ b/js/swad16.205.js @@ -39,7 +39,7 @@ var countClockConnected = 0; /****************** Write a date in client local time ************************/ //id is the id of the HTML element in which date will be written //TimeUTC is the date-time to write in UTC UNIX time format - +/* function writeLocalDateFromUTC (id,TimeUTC,StrToday) { var today = new Date(); var todayYea = today.getFullYear(); @@ -66,13 +66,17 @@ function writeLocalDateFromUTC (id,TimeUTC,StrToday) { document.getElementById(id).innerHTML = Yea + '-' + StrMon + '-' + StrDay; } - +*/ /*************** Write a date-time in client local time **********************/ // id is the id of the HTML element in which date-time will be written // TimeUTC is the date-time to write in UTC UNIX time format +// DateFormat: +// Dat_FORMAT_YYYY_MM_DD = 0 +// Dat_FORMAT_DD_MONTH_YYYY = 1 +// Dat_FORMAT_MONTH_DD_YYYY = 2 // separator is HTML code to write between date and time -function writeLocalDateHMSFromUTC (id,TimeUTC,Separator,StrToday, +function writeLocalDateHMSFromUTC (id,TimeUTC,DateFormat,Separator,StrToday, WriteDateOnSameDay,WriteWeekDay,WriteSeconds) { // HMS: Hour, Minutes, Seconds var today = new Date(); @@ -111,16 +115,43 @@ function writeLocalDateHMSFromUTC (id,TimeUTC,Separator,StrToday, /* Set date */ if (WriteDate) { - StrMon = ((Mon < 10) ? '-0' : '-') + Mon; - StrDay = ((Day < 10) ? '-0' : '-') + Day; - + switch (DateFormat) { + case 0: // Dat_FORMAT_YYYY_MM_DD + StrMon = ((Mon < 10) ? '0' : '') + Mon; + break; + case 1: // Dat_FORMAT_DD_MONTH_YYYY + StrMon = MonthsShort[Mon - 1]; + break; + case 2: // Dat_FORMAT_MONTH_DD_YYYY + StrMon = MonthsShort[Mon - 1]; + break; + default: + StrMon = ''; + break; + } + StrDay = ((Day < 10) ? '0' : '') + Day; + if (Yea == todayYea && Mon == todayMon && Day == todayDay && // Today StrToday.length) StrDate = StrToday; - else - StrDate = Yea.toString() + StrMon + StrDay; + else { + switch (DateFormat) { + case 0: // Dat_FORMAT_YYYY_MM_DD + StrDate = Yea.toString() + '-' + StrMon + '-' + StrDay; + break; + case 1: // Dat_FORMAT_DD_MONTH_YYYY + StrDate = StrDay + ' ' + StrMon + ' ' + Yea.toString(); + break; + case 2: // Dat_FORMAT_MONTH_DD_YYYY + StrDate = StrMon + ' ' + StrDay + ', ' + Yea.toString(); + break; + default: + StrDate = ''; + break; + } + } if (WriteWeekDay) { DayOfWeek = d.getDay(); @@ -1096,7 +1127,7 @@ function DrawMonth (id,FirstDayOfWeek,YearToDraw,MonthToDraw,CurrentMonth,Curren ''; } - Gbl_HTMLContent += MONTHS_CAPS[MonthToDraw - 1] + ' ' + YearToDraw; + Gbl_HTMLContent += Months[MonthToDraw - 1] + ' ' + YearToDraw; if (DrawingCalendar) Gbl_HTMLContent += ''; else diff --git a/swad_agenda.c b/swad_agenda.c index 8f2cd0a06..99a53a16c 100644 --- a/swad_agenda.c +++ b/swad_agenda.c @@ -751,22 +751,23 @@ static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod) fprintf (Gbl.F.Out,"" "" "" "", UniqueId, AgdEvent.Hidden ? Dat_TimeStatusClassHidden[AgdEvent.TimeStatus] : Dat_TimeStatusClassVisible[AgdEvent.TimeStatus], Gbl.RowEvenOdd, - UniqueId,AgdEvent.TimeUTC[Agd_START_TIME],Txt_Today); + UniqueId,AgdEvent.TimeUTC[Agd_START_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* End date/time */ UniqueId++; fprintf (Gbl.F.Out,"" "" "", UniqueId, @@ -774,8 +775,7 @@ static void Agd_ShowOneEvent (Agd_AgendaType_t AgendaType,long AgdCod) Dat_TimeStatusClassVisible[AgdEvent.TimeStatus], Gbl.RowEvenOdd, UniqueId,AgdEvent.TimeUTC[Agd_END_TIME], - - Txt_Today); + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* Event */ fprintf (Gbl.F.Out,"" diff --git a/swad_assignment.c b/swad_assignment.c index 2f39533d3..dd2976b69 100644 --- a/swad_assignment.c +++ b/swad_assignment.c @@ -380,12 +380,12 @@ static void Asg_ShowOneAssignment (long AsgCod,bool PrintView) fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"\">" "" "", - UniqueId, - Asg.TimeUTC[Dat_START_TIME],Txt_Today); + UniqueId,Asg.TimeUTC[Dat_START_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* End date/time */ UniqueId++; @@ -399,12 +399,12 @@ static void Asg_ShowOneAssignment (long AsgCod,bool PrintView) fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"\">" "" "", - UniqueId, - Asg.TimeUTC[Dat_END_TIME],Txt_Today); + UniqueId,Asg.TimeUTC[Dat_END_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* Assignment title */ fprintf (Gbl.F.Out,"" "" "", - UniqueId,Att->TimeUTC[Att_START_TIME],Txt_Today); + UniqueId,Att->TimeUTC[Att_START_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* End date/time */ fprintf (Gbl.F.Out,"" "" "", - UniqueId,Att->TimeUTC[Att_END_TIME],Txt_Today); + UniqueId,Att->TimeUTC[Att_END_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* Attendance event title */ fprintf (Gbl.F.Out," %s" "" "" "" "" @@ -3091,7 +3093,7 @@ static void Att_ListEventsToSelect (Att_TypeOfView_t TypeOfView) Gbl.RowEvenOdd, NumAttEvent,UniqueId,Gbl.AttEvents.Lst[NumAttEvent].Title, UniqueId,Gbl.AttEvents.Lst[NumAttEvent].TimeUTC[Att_START_TIME], - Txt_Today, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today, Gbl.RowEvenOdd, Gbl.AttEvents.Lst[NumAttEvent].NumStdsTotal); } @@ -3487,8 +3489,8 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat) " alt=\"%s\" title=\"%s\" class=\"ICO20x20\" />" " %s" "" "" "", @@ -3506,7 +3508,7 @@ static void Att_ListAttEventsForAStd (unsigned NumStd,struct UsrData *UsrDat) UniqueId, Gbl.AttEvents.Lst[NumAttEvent].Title, UniqueId,Gbl.AttEvents.Lst[NumAttEvent].TimeUTC[Att_START_TIME], - Txt_Today); + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /***** Write comments for this student *****/ if (ShowCommentStd || ShowCommentTch) diff --git a/swad_changelog.h b/swad_changelog.h index c9247abf9..5e5a411ee 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -233,13 +233,14 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.204 (2017-05-04)" -#define CSS_FILE "swad16.202.css" -#define JS_FILE "swad16.181.js" +#define Log_PLATFORM_VERSION "SWAD 16.205 (2017-05-04)" +#define CSS_FILE "swad16.205.css" +#define JS_FILE "swad16.205.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.205: May 04, 2017 Dates written depending on user's preferences. (218721 lines) Version 16.204: May 04, 2017 Form in preferences to change date format. (218656 lines) 3 changes necessary in database: INSERT INTO actions (ActCod,Language,Obsolete,Txt) VALUES ('1638','es','N','Cambiar formato de fecha'); diff --git a/swad_date.c b/swad_date.c index 0004148fd..bf13e1933 100644 --- a/swad_date.c +++ b/swad_date.c @@ -1444,6 +1444,7 @@ void Dat_AssignDate (struct Date *DateDst,struct Date *DateSrc) void Dat_WriteScriptMonths (void) { extern const char *Txt_MONTHS_SMALL[12]; + extern const char *Txt_MONTHS_SMALL_SHORT[12]; unsigned NumMonth; fprintf (Gbl.F.Out,"var Months = ["); @@ -1456,4 +1457,15 @@ void Dat_WriteScriptMonths (void) fprintf (Gbl.F.Out,"'%s'",Txt_MONTHS_SMALL[NumMonth]); } fprintf (Gbl.F.Out,"];\n"); + + fprintf (Gbl.F.Out,"var MonthsShort = ["); + for (NumMonth = 0; + NumMonth < 12; + NumMonth++) + { + if (NumMonth) + fprintf (Gbl.F.Out,","); + fprintf (Gbl.F.Out,"'%s'",Txt_MONTHS_SMALL_SHORT[NumMonth]); + } + fprintf (Gbl.F.Out,"];\n"); } diff --git a/swad_file_browser.c b/swad_file_browser.c index b5b973904..1384c44bf 100644 --- a/swad_file_browser.c +++ b/swad_file_browser.c @@ -6044,11 +6044,11 @@ static void Brw_WriteDatesAssignment (void) Gbl.FileBrowser.Asg.Open ? "ASG_LST_DATE_GREEN" : "ASG_LST_DATE_RED"); fprintf (Gbl.F.Out,"", - UniqueId, - (long) Gbl.FileBrowser.Asg.TimeUTC[Dat_START_TIME],Txt_Today); + UniqueId,(long) Gbl.FileBrowser.Asg.TimeUTC[Dat_START_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); fprintf (Gbl.F.Out,""); /***** Arrow *****/ @@ -6065,11 +6065,11 @@ static void Brw_WriteDatesAssignment (void) Gbl.FileBrowser.Asg.Open ? "ASG_LST_DATE_GREEN" : "ASG_LST_DATE_RED"); fprintf (Gbl.F.Out,"", - UniqueId, - (long) Gbl.FileBrowser.Asg.TimeUTC[Dat_END_TIME],Txt_Today); + UniqueId,(long) Gbl.FileBrowser.Asg.TimeUTC[Dat_END_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); fprintf (Gbl.F.Out,""); } else @@ -6109,11 +6109,12 @@ static void Brw_WriteFileSizeAndDate (struct FileMetadata *FileMetadata) UniqueId++; fprintf (Gbl.F.Out,"" "", UniqueId, - UniqueId,(long) FileMetadata->Time,Txt_Today); + UniqueId,(long) FileMetadata->Time, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); } fprintf (Gbl.F.Out,""); } @@ -9192,14 +9193,15 @@ void Brw_ShowFileMetadata (void) "" "" "" "" "", The_ClassForm[Gbl.Prefs.Theme], Txt_Date_of_creation, - (long) FileMetadata.Time,Txt_Today); + (long) FileMetadata.Time, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /***** Private or public? *****/ fprintf (Gbl.F.Out,"" diff --git a/swad_forum.c b/swad_forum.c index 10a95ef26..45b0cce1b 100644 --- a/swad_forum.c +++ b/swad_forum.c @@ -3406,12 +3406,13 @@ static void For_ListForumThrs (long ThrCods[Pag_ITEMS_PER_PAGE], UniqueId++; fprintf (Gbl.F.Out,"" "" "", UniqueId,Style,BgColor, - UniqueId,(long) TimeUTC,Txt_Today); + UniqueId,(long) TimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); } else for (Column = 1; diff --git a/swad_group.c b/swad_group.c index 664538abb..e50eba41f 100644 --- a/swad_group.c +++ b/swad_group.c @@ -2071,12 +2071,13 @@ static void Grp_WriteGrpHead (struct GroupType *GrpTyp) fprintf (Gbl.F.Out,"
%s: " "" "", Txt_Opening_of_groups, UniqueId, - UniqueId,(long) GrpTyp->OpenTimeUTC,Txt_Today); + UniqueId,(long) GrpTyp->OpenTimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); } fprintf (Gbl.F.Out,"" ""); diff --git a/swad_message.c b/swad_message.c index c1ba5b9da..a37bb8f93 100644 --- a/swad_message.c +++ b/swad_message.c @@ -3525,10 +3525,11 @@ void Msg_WriteMsgDate (time_t TimeUTC,const char *ClassBackground) /***** Write date and time *****/ fprintf (Gbl.F.Out,"", - UniqueId,(long) TimeUTC,Txt_Today); + UniqueId,(long) TimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /***** End cell *****/ fprintf (Gbl.F.Out,""); diff --git a/swad_notice.c b/swad_notice.c index 86ed29c5f..e0e9049f4 100644 --- a/swad_notice.c +++ b/swad_notice.c @@ -703,11 +703,12 @@ static void Not_DrawANotice (Not_Listing_t TypeNoticesListing, Act_FormEnd (); } fprintf (Gbl.F.Out,"" "", - UniqueId,(long) TimeUTC,Txt_Today); + UniqueId,(long) TimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /***** Write the content of the notice *****/ if (TypeNoticesListing == Not_LIST_BRIEF_NOTICES) diff --git a/swad_profile.c b/swad_profile.c index a59a133c1..1733b5f0c 100644 --- a/swad_profile.c +++ b/swad_profile.c @@ -455,10 +455,13 @@ void Prf_ShowDetailsUserProfile (const struct UsrData *UsrDat) (UsrFigures.NumDays == 1) ? Txt_day : Txt_days); fprintf (Gbl.F.Out,"", - IdFirstClickTime, - (long) UsrFigures.FirstClickTimeUTC,Txt_Today); + "writeLocalDateHMSFromUTC('%s',%ld," + "%u,', ','%s',true,false,false);" + "", + IdFirstClickTime,(long) UsrFigures.FirstClickTimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); + + } else // First click time is unknown or user never logged /***** Button to fetch and store first click time *****/ diff --git a/swad_social.c b/swad_social.c index e3583cb8d..dcdf07257 100644 --- a/swad_social.c +++ b/swad_social.c @@ -1625,10 +1625,11 @@ static void Soc_WriteDateTime (time_t TimeUTC) // This must be out of the div where the output is written // because it will be evaluated in a loop in JavaScript fprintf (Gbl.F.Out,"", - IdDateTime,(long) TimeUTC,Txt_Today); + IdDateTime,(long) TimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); } /*****************************************************************************/ diff --git a/swad_statistic.c b/swad_statistic.c index 90e39730d..525142811 100644 --- a/swad_statistic.c +++ b/swad_statistic.c @@ -1771,12 +1771,13 @@ static void Sta_ShowDetailedAccessesList (unsigned long NumRows,MYSQL_RES *mysql /* Write the date-time (row[3]) */ fprintf (Gbl.F.Out,"" "" "", UniqueId,Gbl.RowEvenOdd, - UniqueId,(long) Dat_GetUNIXTimeFromStr (row[3]),Txt_Today); + UniqueId,(long) Dat_GetUNIXTimeFromStr (row[3]), + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* Write the action */ if (sscanf (row[4],"%ld",&ActCod) != 1) @@ -8948,7 +8949,7 @@ static void Sta_GetAndShowNumUsrsPerDateFormat (void) Format <= (Dat_Format_t) (Dat_NUM_OPTIONS_FORMAT - 1); Format++) fprintf (Gbl.F.Out,"" - "" + "" "%s" "" "" diff --git a/swad_survey.c b/swad_survey.c index cc4fac13e..3e23e7208 100644 --- a/swad_survey.c +++ b/swad_survey.c @@ -462,11 +462,12 @@ static void Svy_ShowOneSurvey (long SvyCod,struct SurveyQuestion *SvyQst, fprintf (Gbl.F.Out," COLOR%u",Gbl.RowEvenOdd); fprintf (Gbl.F.Out,"\">" "" "", - UniqueId,Svy.TimeUTC[Svy_START_TIME],Txt_Today); + UniqueId,Svy.TimeUTC[Svy_START_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* End date/time */ fprintf (Gbl.F.Out,"" "" "", - UniqueId,Svy.TimeUTC[Svy_END_TIME],Txt_Today); + UniqueId,Svy.TimeUTC[Svy_END_TIME], + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* Survey title */ fprintf (Gbl.F.Out,"." "", Txt_You_can_not_take_a_new_test_until, - (long) TimeNextTestUTC,Txt_Today); + (long) TimeNextTestUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); Lay_ShowAlert (Lay_WARNING,Gbl.Message); return false; @@ -2855,12 +2856,13 @@ static void Tst_ListOneOrMoreQuestionsToEdit (unsigned long NumRows,MYSQL_RES *m fprintf (Gbl.F.Out,"" "" "", UniqueId,Gbl.RowEvenOdd, - UniqueId,(long) TimeUTC,Txt_Today); + UniqueId,(long) TimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* Write the question tags */ fprintf (Gbl.F.Out,"", @@ -7329,12 +7331,13 @@ static void Tst_ShowTestResults (struct UsrData *UsrDat) UniqueId++; fprintf (Gbl.F.Out,"" "" "", UniqueId,ClassDat,Gbl.RowEvenOdd, - UniqueId,(long) TimeUTC,Txt_Today); + UniqueId,(long) TimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* Get number of questions (row[3]) */ if (sscanf (row[3],"%u",&NumQstsInThisTest) != 1) @@ -7712,12 +7715,13 @@ void Tst_ShowOneTestResult (void) "" "" "" "" "", - Txt_Date,TstTimeUTC,Txt_Today); + Txt_Date,TstTimeUTC, + (unsigned) Gbl.Prefs.DateFormat,Txt_Today); /* Number of questions */ fprintf (Gbl.F.Out,""