[IMP] web_calendar: Display in user's language time format
- Y axis : according to 12 hour or 24 hour format - Event title : following time format in preferenced language NB: The conversion from 'A' to 'TT' to match fullcalendar v1 should be removed when fullcalendar is updated to v2, as the syntax will change. See : http://fullcalendar.io/wiki/Upgrading-to-v2/
This commit is contained in:
committed by
Yannick Tivisse
parent
f6dc57b47c
commit
c1d813ec1c
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user