Why does FullCalendar renders this event as single day event?

大憨熊 提交于 2019-12-13 21:27:52

问题


This is JSON representation of event:

    "id" : 253,
    "title" : "16-17",
    "allDay" : true,
    "start" : "2015-04-16T00:00:00.000+03:00",
    "end" : "2015-04-17T00:30:00.000+03:00"

FullCalendar renders it as single day event. I suspect that the problem is in timezone settings, but can't understand what exactly.

I've tried to use: ignoreTimezone: false but it didn't help.

I suppose that JSON above will render full day event from 16th to 17th (two day event).

Thank you.

UPDATE: I'm using FullCalendar v2.3.1 and there's a link to jsfiddle which reproduces this issue: http://jsfiddle.net/anatoly314/m8d68v1b/4/


回答1:


None of the automated tests in the current version of FullCalendar appear to cover the case in which the start and end dates include times AND the allDay option is set.

Documentation indicates that end dates are exclusive. I strongly suspect that what is happening is that with allDay : true, fullCalendar is stripping the times off of the start and end dates and treating them as T00:00:00. At that point, your event has a start time of 2015-04-16T00:00:00.000 and an end time of 2015-04-17T00:00:00.000, which matches the behavior you're seeing. In fact, if you omit the times from your data and give it:

start: '2015-04-16',
end: '2015-04-17'

it produces a one-day event.

It looks like if you want your event to span two days, you'll need to 'round up' your end time to the beginning of the next day.



来源:https://stackoverflow.com/questions/29732516/why-does-fullcalendar-renders-this-event-as-single-day-event

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