Mutliple business hours in full calendar with two shifts each day

纵饮孤独 提交于 2019-12-05 15:37:09

I also needed the same feature. I forked the repo to

https://github.com/dtmonterrey/fullcalendar

and implemented a solution that works for me. It works with a single businessHours definition or with an array of businessHours definitions (like the example you tried).

Example:

    businessHours:[ 
        {
            start: '09:00',
            end: '13:00',
            dow: [1, 2]
        },
        {
            start: '14:00',
            end: '16:00',
            dow: [1, 2]
        },
        {
            start: '10:00',
            end: '19:00',
            dow: [4]
        },
        {
            start: '06:00',
            end: '10:30',
            dow: [6]
        },
        {
            start: '13:00',
            end: '17:00',
            dow: [6]
        },
        {
            start: '20:00',
            end: '23:00',
            dow: [6]
        }
    ]

I have created a pull request. Suggestions are welcome.

example and demo

I couldn't get jsfiddle to work, so the demo for

http://jsfiddle.net/t7aczbdt/

is here

http://eo14.com/static/fullcalendar/

You could try it on your computer: uncompress this http://eo14.com/static/fullcalendar.zip and open with your browser.

We can add each of our business hours as events with the following options - this is the standard options that fullcalendar works with to populate the businessHours option:-

{
  ...
  events: [
    // business hours 1
    {
        className: 'fc-nonbusiness',
        start: '09:00',
        end: '17:00',
        dow: [1, 2, 3, 4], // monday - thursday
        rendering: 'inverse-background'
    },
    // business hours 2
    {
        className: 'fc-nonbusiness',
        start: '10:00',
        end: '15:00',
        dow: [6], // saturday
        rendering: 'inverse-background'
    }],
 ...
}

Note the magic is done by className : fc-nonbusiness which is counter-intutive; however, that is reversed by the option rendering:'inverse-background and all works well.

Good Luck.

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