Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@coozzy/cal-dav

Package Overview
Dependencies
Maintainers
3
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@coozzy/cal-dav - npm Package Compare versions

Comparing version 2.6.31 to 2.6.32

1

dist/index.d.ts

@@ -56,2 +56,3 @@ import * as ICAL from 'ical.js';

private getStringDateWithoutTime;
private convertUTCtoLocal;
}

@@ -254,3 +254,3 @@ "use strict";

let exceptionEventString = '';
if (event.toString().toLowerCase().includes('x-propbase-recurrence-id')) {
if (event.toString().toLowerCase().includes('recurrence-id')) {
// 4. case: occurrence event of recurrence which we have NOT in database

@@ -426,3 +426,3 @@ // occurrence ical string will be created via Event.iterator

}
const xPropbaseRecurrenceId = event.component.getFirstProperty('x-propbase-recurrence-id');
const xPropbaseRecurrenceId = event.component.getFirstProperty('recurrence-id');
let recurrenceIdString = '';

@@ -440,4 +440,4 @@ if (recurrenceId) {

} else if (recurrenceIdString) {
event.component.removeAllProperties('x-propbase-recurrence-id');
event.component.addPropertyWithValue('X-PROPBASE-RECURRENCE-ID', recurrenceIdString);
event.component.removeAllProperties('recurrence-id');
event.component.addPropertyWithValue('RECURRENCE-ID', recurrenceIdString);
}

@@ -624,3 +624,3 @@ if (attendees.length) {

if (!isRecurring) {
const recurrenceIdProperty = iCalEvent.component.getFirstProperty('x-propbase-recurrence-id');
const recurrenceIdProperty = iCalEvent.component.getFirstProperty('recurrence-id');
if (recurrenceIdProperty) {

@@ -915,2 +915,27 @@ iCalEvent.occurrenceEventDate = this.icalStringToIcalTime(recurrenceIdProperty);

}
convertUTCtoLocal(icsContent) {
// Function to convert UTC datetime strings to local time and remove 'Z'
const convertDateTime = datetime => {
// Parse the datetime string to a Date object
const year = parseInt(datetime.slice(0, 4), 10);
const month = parseInt(datetime.slice(4, 6), 10) - 1; // Month is 0-indexed
const day = parseInt(datetime.slice(6, 8), 10);
const hours = parseInt(datetime.slice(9, 11), 10);
const minutes = parseInt(datetime.slice(11, 13), 10);
const seconds = parseInt(datetime.slice(13, 15), 10);
// Create a Date object in UTC
const utcDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
// Convert to local time by getting the ISO string and formatting it
const localDate = new Date(utcDate.getTime() - utcDate.getTimezoneOffset() * 60000);
const localFormatted = localDate.toISOString().replace(/[:-]/g, '').replace(/\.\d{3}/, '');
return localFormatted;
};
// Replace DTSTART and DTEND with converted local time
icsContent = icsContent.replace(/DTSTART:(\d{8}T\d{6})Z/g, (_, datetime) => `DTSTART:${convertDateTime(datetime)}`);
icsContent = icsContent.replace(/DTEND:(\d{8}T\d{6})Z/g, (_, datetime) => `DTEND:${convertDateTime(datetime)}`);
return icsContent;
}
}

@@ -917,0 +942,0 @@ exports.DefaultCalDavClient = DefaultCalDavClient;

2

package.json
{
"name": "@coozzy/cal-dav",
"version": "2.6.31",
"version": "2.6.32",
"description": "Simple cal dav client.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -8,2 +8,3 @@ import * as ICAL from 'ical.js';

import {htmlToText} from 'html-to-text';
import * as fs from "node:fs";

@@ -89,3 +90,3 @@ export interface CalDavClient {

if(response.status === 200) {
const calData = ICAL.parse(response.data);
const calData = ICAL.parse(response.data);
const comp = new ICAL.Component(calData);

@@ -347,3 +348,3 @@ const vevents = comp.getAllSubcomponents('vevent');

let exceptionEventString = '';
if (event.toString().toLowerCase().includes('x-propbase-recurrence-id')) {
if (event.toString().toLowerCase().includes('recurrence-id')) {
// 4. case: occurrence event of recurrence which we have NOT in database

@@ -542,3 +543,3 @@ // occurrence ical string will be created via Event.iterator

}
const xPropbaseRecurrenceId = event.component.getFirstProperty('x-propbase-recurrence-id');
const xPropbaseRecurrenceId = event.component.getFirstProperty('recurrence-id');
let recurrenceIdString = '';

@@ -557,4 +558,4 @@ if (recurrenceId) {

} else if (recurrenceIdString) {
event.component.removeAllProperties('x-propbase-recurrence-id');
event.component.addPropertyWithValue('X-PROPBASE-RECURRENCE-ID', recurrenceIdString);
event.component.removeAllProperties('recurrence-id');
event.component.addPropertyWithValue('RECURRENCE-ID', recurrenceIdString);
}

@@ -813,3 +814,3 @@

if (!isRecurring) {
const recurrenceIdProperty = iCalEvent.component.getFirstProperty('x-propbase-recurrence-id');
const recurrenceIdProperty = iCalEvent.component.getFirstProperty('recurrence-id');
if (recurrenceIdProperty) {

@@ -1114,2 +1115,29 @@ iCalEvent.occurrenceEventDate = this.icalStringToIcalTime(recurrenceIdProperty);

}
private convertUTCtoLocal(icsContent: string): string {
// Function to convert UTC datetime strings to local time and remove 'Z'
const convertDateTime = (datetime: string): string => {
// Parse the datetime string to a Date object
const year = parseInt(datetime.slice(0, 4), 10);
const month = parseInt(datetime.slice(4, 6), 10) - 1; // Month is 0-indexed
const day = parseInt(datetime.slice(6, 8), 10);
const hours = parseInt(datetime.slice(9, 11), 10);
const minutes = parseInt(datetime.slice(11, 13), 10);
const seconds = parseInt(datetime.slice(13, 15), 10);
// Create a Date object in UTC
const utcDate = new Date(Date.UTC(year, month, day, hours, minutes, seconds));
// Convert to local time by getting the ISO string and formatting it
const localDate = new Date(utcDate.getTime() - (utcDate.getTimezoneOffset() * 60000));
const localFormatted = localDate.toISOString().replace(/[:-]/g, '').replace(/\.\d{3}/, '');
return localFormatted;
};
// Replace DTSTART and DTEND with converted local time
icsContent = icsContent.replace(/DTSTART:(\d{8}T\d{6})Z/g, (_, datetime) => `DTSTART:${convertDateTime(datetime)}`);
icsContent = icsContent.replace(/DTEND:(\d{8}T\d{6})Z/g, (_, datetime) => `DTEND:${convertDateTime(datetime)}`);
return icsContent;
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc