FullCalendar 正在向服务器发送奇数开始和结束值以获取事件

FullCalendar is sending the server an odd start and end value to fetch the events

我正在尝试使用 FullCalendar v5 插件在我的网站上添加日历。我想使用 AJAX 请求获取事件。

这是我所做的

let calendarElement = document.getElementById('calendarElement');

let calendar = new FullCalendar.Calendar(calendarElement, {
            initialView: 'dayGridMonth',
            aspectRatio: 2.0,
            headerToolbar: {
                left: 'prev,next',
                center: 'title',
                end: 'dayGridMonth,timeGridWeek,listWeek, today prev,next'
            },
            weekNumbers: false,
            lazyFetching: false,
            events: {
                url: '/events',
                method: 'GET',
                startParam: 'start', // I expect this to always be the begin of the month
                endParam: 'end', // I expect this to always be the end of the month
                failure: function (e) {
                    console.log(e);
                }
            }
        });

calendar.render();

但是,发送到服务器的值似乎有错误的 start/end 值。 /events?start=StartValue&end=EndValue

如果我正在查看 2 月份的事件,我希望插件向服务器发送一个 GET 请求,其中包含 start 和 `2 的 2/1/2022 00:00:00 值/28/2022 23:59:59' 为结束日期。

但是,该插件似乎向服务器发送了奇怪的范围。插件发送值 1/30/2022 5:00:00 AM 作为起始值,3/13/2022 5:00:00 AM 作为结束值。我的 PC 时区是 UTC 的 -5,这解释了 5 个小时。但我希望最终值为 2/28/2022 而不是 3/13/2022

如何解决这个问题,以便插件根据用户的视图发送准确的范围?

这是日历的图片

它不会发送 的第一个日期,它会发送视图中可见的第一个日期,因此不会遗漏任何内容。例如,对于 2022 年 2 月,根据您的屏幕截图,第一个可见日期是 1 月 30 日。与结束日期相同。

但是,如果您将 showNonCurrentDates 选项设置为 false

showNonCurrentDates: false

在您的日历配置中,使用月视图时将不会显示当前月份以外的任何日期 - 它们将显示为灰色。由于其中不会显示任何事件,因此日历不包括它在 AJAX 请求参数中发送的范围内的那些日期 - 而是使用确切的开始和结束月份。