Fullcalendar结束日期错误一天

Cás*_*nho 23 javascript fullcalendar

我正在制作fullCalendar支持的汽车预订功能.这是coffescript文件.

    updateEvent = (event, delta, revertFunc) ->
      $.ajax
        type: "PUT"
        dataType: "json"
        success: (data) ->
            alert "Success"
        error: (data) ->
            revertFunc()
            errors = data.responseJSON.reservations[0][1]
            for message of errors
                alert errors[message]
        url: event.updateUrl
        data:
          reservation:
            reservation_start: event.start.format('DD-MM-YYYY')
            reservation_end: event.end.format('DD-MM-YYYY')
            transport_id: event.transport_id
            user_id: event.user_id

$(document).ready ->
  $(".calendar").fullCalendar
    events: gon.path
    eventDrop: updateEvent
    eventResize: updateEvent
Run Code Online (Sandbox Code Playgroud)

这是带有事件的JSON feed.

[{"start":"2014-12-17T00:00:00.000Z","end":"2014-12-21T00:00:00.000Z","title":"Cassio Godinho","url":"/reservas/44/edit","allDay":true,"editable":true,"updateUrl":"/reservation/44","transport_id":1,"user_id":1}]
Run Code Online (Sandbox Code Playgroud)

end日期2014-12-21,但这是我的日历在此输入图像描述

文档说明了这一点(我认为):

endParam
It is the moment immediately after the event has ended. For example, if the last full day of an event is Thursday, the exclusive end of the event will be 00:00:00 on Friday!
Run Code Online (Sandbox Code Playgroud)

但我不太清楚如何处理这些信息......

Sha*_*ded 10

我认为方向上的关键词是exclusive这样的,无论你指定什么时间都不包括在日期范围内.

所以在你的情况下"2014-12-21T00:00:00.000Z"意味着事件将在12-21开始时不再存在.如果您希望事件通过12-21,您需要将结束时间设置为"2014-12-22T00:00:00.000"(12-22中的第一个可能时间).

  • 所以这意味着,我增加日期.多数民众赞成,没有fullcalendar提供的修复程序吗?有没有办法包括结束日? (5认同)
  • 很好的解释,但绝不能帮助人们解决这个问题。您可以参考一些文档并构建一个解决方案吗? (2认同)

小智 5

我有同样的问题,我终于想通了。

我使用的是全天TRUE,根据文档,如果您使用全天TRUE,它会及时运行。

所以首先,我将全天更改为FALSE,然后

在最后一天,我添加了$ endDate。“ T23:59:00”;

这对我有用。


小智 5

您需要设置 nextDayThreshold: '00:00' 它将显示最后一天!

  • 需要强调的是,当 allDay 为 true 时,在日历本身上设置的 nextDayThreshold 选项将被忽略。https://fullcalendar.io/docs/nextDayThreshold (2认同)