为什么FullCalendar将此事件呈现为单日事件? [英] Why does FullCalendar renders this event as single day event?
问题描述
这是事件的JSON表示:
id:253,
title:16 -17,
allDay:true,
开始:2015-04-16T00:00:00.000 + 03:00,
结束:2015-04 -17T00:30:00.000 + 03:00
FullCalendar将其渲染为单日事件。我怀疑问题是在时区设置,但不明白究竟是什么。
我试过使用: ignoreTimezone:false
但它没有帮助。
我想上面的JSON会在16日到17日(两天的事件)中显示全天事件。
谢谢。
更新:
我使用的是FullCalendar v2.3.1,并有一个jsfiddle的链接,它重现了这个问题: http://jsfiddle.net/anatoly314/m8d68v1b/4/
文档指出结束日期是独占的。我强烈怀疑发生了什么事情,使用 allDay:true
,fullCalendar会剥离开始和结束日期的时间,并将它们视为 T00 :00:00
。此时,您的活动的开始时间为 2015-04-16T00:00:00.000
,结束时间 2015-04-17T00: 00:00.000
,它与您所看到的行为相符。事实上,如果您从数据中省略时间并给出它:
start:'2015-04-16',
end:'2015-04-17'
它会产生一天的活动。 / p>
看起来如果您希望您的活动持续两天,则需要将结束时间整理到第二天的开始时间。
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/
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.
这篇关于为什么FullCalendar将此事件呈现为单日事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!