fix recurring events calendar by using zeroed time data in before and after stamps
This commit is contained in:
parent
909b747bf8
commit
5b8f0a57e7
@ -2,7 +2,7 @@
|
||||
"main": "plugin.js",
|
||||
"name": "calendar",
|
||||
"description": "Plugin for iCalendar/VCS room events",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"tags": ["commands", "utility", "calendar"],
|
||||
"dependencies": ["simplecommands"],
|
||||
"npmDependencies": ["node-ical@^0.12.3"]
|
||||
|
@ -37,6 +37,11 @@ function nts(): number {
|
||||
return Math.floor(Date.now() / 1000);
|
||||
}
|
||||
|
||||
function utcNoHours(start: number): Date {
|
||||
const fts = new Date(start);
|
||||
return new Date(Date.UTC(fts.getFullYear(), fts.getMonth(), fts.getDate()));
|
||||
}
|
||||
|
||||
function eventsFor(msg: IMessage): Event[] {
|
||||
return memcache.filter((ev: Event) => {
|
||||
if (!msg.fullRoomID) {
|
||||
@ -146,8 +151,8 @@ async function fetchCalendars(interval: number): Promise<void> {
|
||||
// Recurring events handling
|
||||
if ('rrule' in data) {
|
||||
const rrule = (data as any).rrule as any;
|
||||
const recurring = rrule.between(new Date(),
|
||||
new Date(Date.now() + cfg.timeFrame * 1000));
|
||||
const recurring = rrule.between(utcNoHours(Date.now()),
|
||||
utcNoHours(Date.now() + cfg.timeFrame * 1000), true);
|
||||
const originalDuration = end - start;
|
||||
for (const date of recurring) {
|
||||
const newStart = Math.floor(new Date(date).getTime() / 1000);
|
||||
|
@ -3,7 +3,7 @@
|
||||
"plugins": [
|
||||
{
|
||||
"name": "calendar",
|
||||
"version": "1.1.0"
|
||||
"version": "1.1.1"
|
||||
},
|
||||
{
|
||||
"name": "debug",
|
||||
|
Loading…
Reference in New Issue
Block a user