agendaDay row time format in fullCalendar

倾然丶 夕夏残阳落幕 提交于 2019-12-12 21:58:26

问题


I am trying to set the time format in my calendar rows to appear as 1pm - 2pm, 2pm - 3pm, 3pm- 4pm, etc.

I have tried the following:

agenda: 'h:mm{ - h:mm}',
axisFormat: 'h:mm{ - h:mm}',  
day: 'h:mm{ - h:mm}', 
axisFormat: 'h(:mm)tt', 
timeFormat: {
    agenda: 'h:mm{ - h:mm}'
},

but none of the above, either alone or in combination seem to work for me.

I initialize my calendar as below:

  $('#calendar').fullCalendar({
    defaultView: 'agendaDay',
    allDaySlot: false,
    firstHour: 9,
    minTime: 9,
    maxTime: 19,
    selectable: true,
    unselectAuto: true,
    slotMinutes: 60,
    weekends: false,
    year: current_year,
    month: current_month,
    date: current_day,
    columnFormat: '',

回答1:


FullCalendar does not provide a "to" time for the axisFormat and therefore the { - h:mm} part of you axisFormat is ignored.

And I don't think there's any way to do it without editing the FullCalendar source code.

But if you are feeling adventurous you could do the following changes in fullcalendar.js around line 3207:

    d = zeroDate();
    maxd = addMinutes(cloneDate(d), maxMinute);
    addMinutes(d, minMinute);

    // Add two lines
    var toD = cloneDate(d);
    addMinutes(toD, opt('slotMinutes'));

    slotCnt = 0;
    for (i=0; d < maxd; i++) {
        minutes = d.getMinutes();
        s +=
            "<tr class='fc-slot" + i + ' ' + (!minutes ? '' : 'fc-minor') + "'>" +
            "<th class='fc-agenda-axis " + headerClass + "'>" +

            // Changed line from "formatDate(d, opt('axisFormat')...)" to "formatDates(d, toD, opt('axisFormat')...)"
            ((!slotNormal || !minutes) ? formatDates(d, toD, opt('axisFormat')) : '&nbsp;') +

            "</th>" +
            "<td class='" + contentClass + "'>" +
            "<div style='position:relative'>&nbsp;</div>" +
            "</td>" +
            "</tr>";
        addMinutes(d, opt('slotMinutes'));

        // Add line
        addMinutes(toD, opt('slotMinutes'));

        slotCnt++;
    }


来源:https://stackoverflow.com/questions/17540473/agendaday-row-time-format-in-fullcalendar

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!