Skip to content

Instantly share code, notes, and snippets.

@mogarick
Last active May 14, 2024 10:16

Revisions

  1. mogarick renamed this gist Feb 27, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.js → utcTimestampsWithTimezone.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    //Please note I'm also using underscore each function for the iterations

    //iCal -> jsCal
    var icalEvents = ICal.parse(iCalStringData);
    //jsCal->Component
  2. mogarick revised this gist Feb 27, 2014. 1 changed file with 35 additions and 1 deletion.
    36 changes: 35 additions & 1 deletion gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,43 @@
    //iCal -> jsCal
    var icalEvents = ICal.parse(iCalStringData);
    //jsCal->Component
    var comp = new Component(icalEvents[1]);

    //Get all VTIMEZONE iCalendar components
    var vtimezones = comp.getAllSubcomponents("vtimezone");
    //Add all timezones in iCalendar object to TimezonService
    //if they are not already registered.
    _.each(vtimezones, function (vtimezone) {
    //Si timezone está registrada

    if (!(ICAL.TimezoneService.has(
    vtimezone.getFirstPropertyValue("tzid")))) {
    ICAL.TimezoneService.register(vtimezone);
    }
    });
    //Get all VEVENT iCalendar components
    var vevents = comp.getAllSubcomponents("vevent");
    var events = [];
    var eventCount = 1;
    _.each(vevents, function (vevent) {
    var event = new Event(vevent);
    //Get the datetime info in UTC format with appropiate offset
    var startDate = new Date(event.startDate.toUnixTime() * 1000);
    var endDate = new Date(event.endDate.toUnixTime() * 1000);
    console.log(eventCount, " - - - - - - - - - - - - - - - - - - ");
    console.log("UID:", event.uid);
    console.log("Recurrent?", event.isRecurring());
    console.log("Start:", startDate);
    console.log("End:", endDate);
    //This also depends on the correct timezone to be present in TimezoneService
    console.log("Duration:",event.duration.toString());
    console.log("Lugar:", event.location);
    console.log("Organizer:", event.organizer);
    console.log("Atendees:", event.attendees);
    console.log("Summary:", event.summary);
    console.log("Description", event.description);
    console.log("\n");

    events.push(event);

    eventCount++;
    });
  3. mogarick created this gist Feb 27, 2014.
    9 changes: 9 additions & 0 deletions gistfile1.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@

    var vtimezones = comp.getAllSubcomponents("vtimezone");
    _.each(vtimezones, function (vtimezone) {
    //Si timezone está registrada
    if (!(ICAL.TimezoneService.has(
    vtimezone.getFirstPropertyValue("tzid")))) {
    ICAL.TimezoneService.register(vtimezone);
    }
    });