diff --git a/addons/web_calendar/static/src/js/web_calendar.js b/addons/web_calendar/static/src/js/web_calendar.js index bdd1d776e78..8eae5225033 100644 --- a/addons/web_calendar/static/src/js/web_calendar.js +++ b/addons/web_calendar/static/src/js/web_calendar.js @@ -21,6 +21,13 @@ var QWeb = core.qweb; function get_fc_defaultOptions() { var dateFormat = time.strftime_to_moment_format(_t.database.parameters.date_format); + // moment.js converts '%p' to 'A' for 'AM/PM' + // But FullCalendar v1.6.4 supports 'TT' format for 'AM/PM' but not 'A' + // NB: should be removed when fullcalendar is updated to 2.0 because it would + // be supported. See the following link + // http://fullcalendar.io/wiki/Upgrading-to-v2/ + var timeFormat = time.strftime_to_moment_format(_t.database.parameters.time_format).replace('A', 'TT'); + // adapt format for fullcalendar v1. // see http://fullcalendar.io/docs1/utilities/formatDate/ var conversions = [['YYYY', 'yyyy'], ['YY', 'y'], ['DDDD', 'dddd'], ['DD', 'dd']]; @@ -28,6 +35,15 @@ function get_fc_defaultOptions() { dateFormat = dateFormat.replace(conv[0], conv[1]); }); + // If 'H' is contained in timeFormat display '10:00' + // Else display '10 AM'. + // See : http://fullcalendar.io/docs1/utilities/formatDate/ + var hourFormat = function(timeFormat){ + if (/H/.test(timeFormat)) + return 'HH:mm'; + return 'hh TT'; + }; + return { weekNumberTitle: _t("W"), allDayText: _t("All day"), @@ -39,6 +55,10 @@ function get_fc_defaultOptions() { weekNumberCalculation: function(date) { return moment(date).week(); }, + axisFormat: hourFormat(timeFormat), + // Correct timeformat for agendaWeek and agendaDay + // http://fullcalendar.io/docs1/text/timeFormat/ + timeFormat: timeFormat + ' {- ' + timeFormat + '}', weekNumbers: true, titleFormat: { month: 'MMMM yyyy',