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