javascript - 日历结束日期错了一天

我正在制作一个完整的日历支持的汽车预订功能。 这是 CoffeeScript 文件。

    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

这是带有事件的 JSON 提要。

[{"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}]

结束 日期是 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!

但我不太确定如何处理这些信息...

最佳答案

我认为说明中的关键词是exclusive,所以无论您指定的时间都不会包含在日期范围内。

因此,在您的情况下,"2014-12-21T00:00:00.000Z" 将意味着该事件将不再存在于 12-21 年初。如果您希望事件在 12-21 结束,您需要将结束时间设置为 "2014-12-22T00:00:00.000"(第一个可能的时间在 12-22)。

https://stackoverflow.com/questions/27407052/

相关文章:

json - d3 - 读取 JSON 数据而不是 CSV 文件

html - "modern"浏览器 "handle"一次可以有多少个 HTML 元素?

php - Android JSON HttpClient 使用 HttpResponse 将数据发

jquery - 你使用 Ajax JSON 还是 HTML?

javascript - Chrome 扩展 "Refused to evaluate a stri

android - 如何使用 Android Lollipop 中的注释在 Android Jack

c# - Json空数组在MVC中反序列化为null

c# - WebApi Put如何从指定的属性中告诉未指定的属性设置为null?

json - getJSON 与 optJSON

.net - JSON.NET 教程