Code Monkey home page Code Monkey logo

node-icalendar's People

Contributors

aramk avatar asalant avatar clarkbw avatar cwohlman avatar gheeres avatar jagregory avatar james-emerton avatar joshhunt avatar jugglinmike avatar lefnire avatar leider avatar mattkalina avatar purge avatar randypuro avatar rblu avatar tmcw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-icalendar's Issues

VEvent setters adding redundant copies of a given property.

If I create an event and use VEvent.setSummary() and then use it again, two SUMMARY properties end up getting added to the event. This is because they use CalendarObject.addProperty().

Shouldn't the VEvent setters use CalendarObject.setProperty() instead of CalendarObject.addProperty()?

Problems parsing Outlook 2010 Meeting requests

I had problems parsing meeting requests sent by Outlook 2010. Interestingly, those sent by Outlook 2013 were working.

I narrowed down the issue to Outlook 2010 including an empty new line at the end of the meeting request it sends. This meant the vcalender string (received via an imap library) I passed into parse_calender() had extra line breaks. The error that the module kept throwing was "Mismatched BEGIN/END tags", which was confusing.

The way I resolved the problem was flipping the two 'if' statements on lines 202-206 of parser.js to be like so:

for(var i=0; i<data.length-1; ++i) {
if(!data[].length)
continue;

if(state === undefined)
throw new ParseError("Mismatched BEGIN/END tags");

Outlook and Live needs UID

When creating a collection of events it's not possible to set a unique id on the VEVENT using addComponent (or is it?). This causes problems when trying to subscribe to the calendar in outlook and on live.com.

For example, live.com gives the error "This calendar wasn't updated because of a problem with the publisher's file (the file's events don't have UID properties). We'll try updating it again later."

Bug or local misconfiguration? On my local installation 3 Tests are red

Transcript:

  1) RRule respects COUNT parts
   Message:
     Expected [ Date(Sat Jan 01 2011 00:00:00 GMT+0100 (CET)), Date(Tue Feb 01 2011 00:00:00 GMT+0100 (CET)) ] to equal [ Date(Sat Jan 01 2011 00:00:00 GMT+0100 (CET)), Date(Tue Feb 01 2011 00:00:00 GMT+0100 (CET)), Date(Tue Mar 01 2011 00:00:00 GMT+0100 (CET)) ].
   Stacktrace:
     Error: Expected [ Date(Sat Jan 01 2011 00:00:00 GMT+0100 (CET)), Date(Tue Feb 01 2011 00:00:00 GMT+0100 (CET)) ] to equal [ Date(Sat Jan 01 2011 00:00:00 GMT+0100 (CET)), Date(Tue Feb 01 2011 00:00:00 GMT+0100 (CET)), Date(Tue Mar 01 2011 00:00:00 GMT+0100 (CET)) ].
    at null.<anonymous> (/JavascriptDev/node-icalendar/spec/rrule-spec.js:43:18)

  2) RRule respects EXDATE full date parts
   Message:
     Expected [ Date(Sat Jan 01 2011 10:00:00 GMT+0100 (CET)), Date(Tue Feb 01 2011 10:00:00 GMT+0100 (CET)), Date(Fri Apr 01 2011 10:00:00 GMT+0200 (CEST)) ] to equal [ Date(Sat Jan 01 2011 10:00:00 GMT+0100 (CET)), Date(Fri Apr 01 2011 10:00:00 GMT+0200 (CEST)), Date(Sun May 01 2011 10:00:00 GMT+0200 (CEST)) ].
   Stacktrace:
     Error: Expected [ Date(Sat Jan 01 2011 10:00:00 GMT+0100 (CET)), Date(Tue Feb 01 2011 10:00:00 GMT+0100 (CET)), Date(Fri Apr 01 2011 10:00:00 GMT+0200 (CEST)) ] to equal [ Date(Sat Jan 01 2011 10:00:00 GMT+0100 (CET)), Date(Fri Apr 01 2011 10:00:00 GMT+0200 (CEST)), Date(Sun May 01 2011 10:00:00 GMT+0200 (CEST)) ].
    at null.<anonymous> (/JavascriptDev/node-icalendar/spec/rrule-spec.js:84:18)

  3) VEvent objects uses EXDATE properties when calculating recurrence
   Message:
     Expected [ Date(Sat Jan 01 2011 10:00:00 GMT+0100 (CET)), Date(Tue Feb 01 2011 10:00:00 GMT+0100 (CET)), Date(Fri Apr 01 2011 10:00:00 GMT+0200 (CEST)) ] to equal [ Date(Sat Jan 01 2011 10:00:00 GMT+0100 (CET)), Date(Fri Apr 01 2011 10:00:00 GMT+0200 (CEST)), Date(Sun May 01 2011 10:00:00 GMT+0200 (CEST)) ].
   Stacktrace:
     Error: Expected [ Date(Sat Jan 01 2011 10:00:00 GMT+0100 (CET)), Date(Tue Feb 01 2011 10:00:00 GMT+0100 (CET)), Date(Fri Apr 01 2011 10:00:00 GMT+0200 (CEST)) ] to equal [ Date(Sat Jan 01 2011 10:00:00 GMT+0100 (CET)), Date(Fri Apr 01 2011 10:00:00 GMT+0200 (CEST)), Date(Sun May 01 2011 10:00:00 GMT+0200 (CEST)) ].
    at null.<anonymous> (/JavascriptDev/node-icalendar/spec/vevent-spec.js:124:18)

0 Duration gets formatted to 'P'

Got across this issue when trying to set a VALARM with a trigger at the time of the event (in other words, with a zero duration).

When I printed the resulting calendar, I noticed that TRIGGER property was 'P', instead of 'P0D'.

I have been looking at the code and it's not a difficult issue to tackle. However, I have seen that you are currently making all the calculations manually, have you taken a look at the awesome MomentJS library?

From http://momentjs.com/docs/#/durations/as-json/:
"When serializing a duration object to JSON, it will be be represented as an ISO8601 string."

If I am making no mistakes, at least DURATION.format method from lib/types can be replaced with moment.duration(value, 'seconds').toJSON()

_UPDATE_
From iCalendar RFC 5545:
"Note that unlike [ISO.8601.2004], this value type doesn't support the "Y" and "M" designators to specify durations in terms of years and months."

Taking into account that moment.duration.toJSON strictly follows ISO8601, then no, MomentJS its not a DIRECT replacement for this method. However, moment.duration object (and the MomentJS library in general) can still reduce A LOT of code.

Example of creating alarm

Hi,

I can't figure out how to create an alarm. Could somebody provide just a simple example of how it is created? Is it attached to an event?

Many thanks.

Suggest capitalizing names of properties

I had used the following:

.addProperty('location', location)

to add a location to my calendar. It turns out that this works on Outlook, but not on Apple Calendar, which seems to require the property to be in all capital letters (ie. LOCATION). I'm not too familiar with the spec, but it looks like this is probably the case with all properties. I would suggest doing a .toUpperCase on the property name as a convenience.

Support Lotus calendars (uses BYMINUTE, BYHOUR, etc.)

This library supports all the types of calendars we receive except for those made using Lotus, because it uses BYMINUTE, BYHOUR, or BYMONTH to describe timezones.

How hard would it be to add support for those? I also am willing to patch myself but would appreciate some direction, thanks.

"BEGIN:VCALENDAR
X-LOTUS-CHARSET:UTF-8
VERSION:2.0
PRODID:-//Lotus Development Corporation//NONSGML Notes 9.0.1//EN_S
METHOD:REPLY
BEGIN:VTIMEZONE
TZID:Eastern Standard Time
BEGIN:STANDARD
DTSTART:19501105T020000
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
RRULE:FREQ=YEARLY;BYMINUTE=0;BYHOUR=2;BYDAY=1SU;BYMONTH=11
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19500312T020000
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
RRULE:FREQ=YEARLY;BYMINUTE=0;BYHOUR=2;BYDAY=2SU;BYMONTH=3
END:DAYLIGHT
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID="Eastern Standard Time":20151028T170000
DTEND;TZID="Eastern Standard Time":20151028T173000
TRANSP:OPAQUE
DTSTAMP:20151019T175722Z
SEQUENCE:4
ATTENDEE;PARTSTAT=ACCEPTED;CN="guest"
;SENT-BY="[email protected]";RSVP=FALSE
:mailto:[email protected]
CLASS:PUBLIC
SUMMARY:coffee chat
LOCATION:NY, NY
ORGANIZER;CN="Foo":mailto:[email protected]
UID:[email protected]
X-LOTUS-UPDATE-SEQ:5
X-LOTUS-NOTESVERSION:2
X-LOTUS-NOTICETYPE:A
X-LOTUS-APPTTYPE:3
X-LOTUS-CHILD-UID:0451FEA019239F5600257EE30062A31A
END:VEVENT
END:VCALENDAR"

RRule Events and DTEND

Hi,
im having trouble with VEVENTS containing RRules and DTEND property. When using rrule.nextOccurences or vevent.inTimeRange dates are only computed until the DTEND and not until the UNTIL statement in the RRule.
Unfortunatly im not able to fix it by myself...

Best regards
vader722

How to capture events for a single day

Hi all.
from parsed .ics data i want to extract events that happen on a specific day (when cycling through rendering of a monthly calendar for example).

This is what i tried:

var startDate = new Date(date); // specific day at 0:00
var endDate = new Date(startDate.getFullYear(), startDate.getMonth(), startDate.getDate(), 23, 59, 59);
var eventsInDay = [];
for (var i = 0; i < allEvents.length; i++) {
    if (allEvents[i].inTimeRange(startDate, endDate)) {
        eventsInDay.push(allEvents[i]);
    }
}

Miserably inTimeRange() returns true for all events on every day, although my recurring events only happen one time a month.

What is wrong with my implementation?

Improve README example

Please add the requires() line and also explain the argument to VEvent. Is it a UUID? Is it required to generate a unique id or is it optional? Perhaps the constructor could generate one and then you could query the object for the id?

var event = new icalendar.VEvent('cded25be-3d7a-45e2-b8fe-8d10c1f8e5a9');
event.setSummary("Test calendar event");
event.setDate(new Date(2011,11,1,17,0,0), new Date(2011,11,1,18,0,0));
event.toString();

Support streams

Hi -

I have a need for getting the calendar as a stream instead of as a string. My requirement is about pushing the calendar up to a pkgcloud service but perhaps others also want another way to serve calendars; see why you should use streams.

I'm wondering if you'd accept a pull request along those lines and if so looking for any guidance you might have.

There are certainly good arguments to be made that much of the calendar object is already in memory so streaming it only saves from creating a large string representation of the objects already in memory. As I said, my request is a bit about convenience operating with things expecting a stream and so performance while nice isn't my top line goal.

Currently I'm using the following to take the calendar toString method and coerce it into into a stream.

var  _      = require('lodash');
var ical   = require('icalendar');
var Readable = require('stream').Readable;

var calendar = new ical.iCalendar();
var s = new Readable();
s._read = _.noop;
s.push(calendar.toString());
s.push(null);
var stream3 = s3.uploadStream('ical', 'uid.ics');
s.pipe(stream3);

My plan is to make the following changes:

  • Use the Readable stream
    • var Readable = require('stream').Readable;
  • CalendarObject inherits from Readable
    • util.inherits(CalendarObject, Readable);
  • Add a _read function which mimics the format and toString function
    • CalendarObject.prototype._read = function(n) {

Probably insert the _read function between the toString and format functions.
https://github.com/tritech/node-icalendar/blob/master/lib/base.js#L236

This change should give the Calendar object ( by inheritance ) the ability to be piped like a stream.

var ical   = require('icalendar');

var calendar = new ical.iCalendar();
var stream3 = s3.uploadStream('ical', 'uid.ics');
calendar.pipe(stream3);

Maybe I'll just write it now that I spec'd it all out.

Add support for all day events

Adding all day events is currently not possible with this package.

The iCalender specification defines all day events like this

DTSTART;VALUE=DATE:19971102
DTEND;VALUE=DATE:19971104

Can't get it working with Google Calendar

I got this to export an .ics which is recognized just fine on Mac Calendar. When I try importing a Google Calendar by URL providing the .ics file's URL, however, GCal will setup a calendar fine but fail to import events.

I've been running the exports through icalvalid to test. One thing I've noticed is node-icalendar produces a date property that fails this test: The value appears to be a 'date' value, but 'VALUE=DATE' was not specified.. I tried fixing that with this line, but still the same problem with GCal. I'm sure it's something I'm doing wrong, but wondered if you had anything top-of-the-dome re: node-icalendar v GCal?

Bug in formatting duration values

The current duration format in types.js does this (on line 130):

if(neg) dur.push('-');

which outputs property values like TRIGGER:P-T11M. Unfortunately, this is wrong (according to the spec at http://www.ietf.org/rfc/rfc2445.txt, it should be negative sign before the P, like dur-value = (["+"] / "-") "P" (dur-date / dur-time / dur-week)

It should really do this:

if(neg) dur.unshift('-');

which would produce the right thing: TRIGGER:-PT11M.

Error parsing calendars with certain valid VTimezone data

When a calendar has a VTIMEZONE block, with both standard and daylight components, but without a RRULE specified (appears to be optional as per RFC) an error is thrown.

"Cannot call method 'next' of null" @
var next_std = this.getRRule('STANDARD').next(dt);
(line 62 of timezone.js)

BEGIN:VTIMEZONE
TZID:E. Australia Standard Time
BEGIN:STANDARD
DTSTART:16010101T000000
TZOFFSETFROM:+1000
TZOFFSETTO:+1000
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:16010101T000000
TZOFFSETFROM:+1000
TZOFFSETTO:+1000
END:DAYLIGHT
END:VTIMEZONE

These kinds of VTIMEZONE blocks are being generated by Outlook for Mac.

RRule not included in toString

Hi im trying to export the calendar into a file '.ics' and i cant get RRule to show up.
I can set nd event's RRule properly in the object, but it will not be included when i attempt to use toString method on the event or calendar object

remove Z from DTSTART/DTEND

How do I prevent this library from adding 'Z' at the end of type DATE-TIME?
DTSTART:20151010T080000Z ---> DTSTART:20151010T080000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.