簡體   English   中英

如何將 fullcalendar 重復事件的結束時間延長到第二天?

[英]How to extend end time of fullcalendar recurring events to the next day?

如何顯示結束時間超過當天的重復事件?

這是一個示例數據:

const data = {
  id: 1,
  title: "ABC",
  startRecur: "2020-06-11T16:00:00.000Z",
  startTime: "23:00:00",
  endTime: "03:00:00",
  daysOfWeek: ["5"]
};

calendar.addEventSource({
  events: [data]
});

基本上開始時間是11:00 PM ,應該在第二天3:00 AM結束。 我如何讓fullcalendar知道它應該在第二天結束? 請注意,這是一個反復發生的事件。

這是它在月視圖中的樣子:

在此處輸入圖像描述

並在周視圖中(未呈現事件,因為它認為結束時間是同一天的凌晨 3 點):

在此處輸入圖像描述

這是問題所在。

我希望它看起來像這樣(谷歌日歷)

在此處輸入圖像描述

更新:使用rrule 插件讓它工作

所以在此之前,我是使用fullcalendar's內置重復事件來完成的。

const data = {
  id: 1,
  title: "ABC",
  startRecur: "2020-06-11T16:00:00.000Z",
  startTime: "23:00:00",
  // endTime is 03:00:00 because I expect it to end the next day at 3 AM
  endTime: "03:00:00",
  daysOfWeek: ["5"]
};

calendar.addEventSource({
  events: [data]
});

這樣做的問題是,當您的endTime小於給定的startTime時, fullcalendar將無法理解它並且不會在日歷中呈現事件。

為了解決這個問題,有一個名為rrule 插件的插件,它允許在幾天內重復發生事件。 謝阿迪森

代替上述添加重復事件的方式,我們可以使用它來代替:

const data = {
  id: 1,
  title: "my recurring event",
  rrule: {
    freq: "weekly",
    interval: 5,
    byweekday: ["fr"],
    // In the above code,
    // start date and start time are separate.
    // In the rrule plugin, dtstart
    // should contain both start date and time.
    dtstart: "2020-06-01T23:00:00"
  },

  // Duration is how long the event will run,
  // not exactly what the time it should end.
  // in our case, to end the event the next day 3 AM.
  // We should add 4 hours.
  duration: "04:00"
};

calendar.addEventSource({
  events: [data]
});

這是一支工作

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM