Giter Site home page Giter Site logo

icalparser's Introduction

icalparser's People

Contributors

aaronpk avatar christiaangoossens avatar cracksalad avatar cyberbeat avatar drewpc avatar gms8994 avatar jfinstrom avatar lfirewall1243 avatar lokonli avatar ozzyczech avatar pierswarmers avatar rotzbua avatar tm1000 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

icalparser's Issues

Error when parsing ics where VALARM comes immeadiately after VEVENT

This feed https://www.stanza.co/api/schedules/nhl-penguins/nhl-penguins.ics has VEVENT blocks with the VALARM immeadiately within it (see below). The parser throws an error in this case

Undefined index: VEVENT
    in file /vendor/om/icalparser/src/IcalParser.php at line 180

I tried to figure out the best approach to get around this but the state-machine logic in there is kind of hard to follow. Any pointers?

BEGIN:VEVENT
BEGIN:VALARM
TRIGGER;VALUE=DURATION:-PT30M
ACTION:DISPLAY
DESCRIPTION:Penguins vs. Blue Jackets
END:VALARM
DTSTART:20170204T000000Z
DTEND:20170204T021500Z
UID:[email protected]
SUMMARY:Penguins vs. Blue Jackets
DESCRIPTION:Penguins vs. Blue Jackets\n\nBuy tickets here: https://stza.co/~lRQk\n\nSynced via Stanza - create your own live updating calendar (https://stanza.co?events)\n\nFor questions, check out Stanza’s FAQs page: https://stanza.co/faqs
LOCATION:PPG Paints Arena, 1001 Fifth Ave, Pittsburgh, PA
STATUS:CONFIRMED
DTSTAMP:20170801T090752Z
CREATED:20170801T090752Z
LAST-MODIFIED:20170801T090752Z
TRANSP:OPAQUE
END:VEVENT

Recurrences only works for 3 years

Unlimited recurring events only works for 3 years because it is limited in class IcalParser in function parseRecurrences
$end = clone($event['DTSTART']);
$end->add(new \DateInterval('P3Y')); // + 3 years

After 3 years the recurring event is not working anymore.

I am working on a solution for this issue, but I am not finished, yet.
Are there any more ideas which could help me?

add a PHP 5.6 Travis build

Since PHP5.4 is near it end of life, and PHP5.6 published since one year, it could be a good thing to add a third build on PHP5.6 on travis CI

Weekly recurring event on specific days missing first day of event

We have an iCal file generated from Google Calendar that we're parsing. It has multiple events that are recurring weekly on Mondays, Tuesdays, Wednesdays, and Thursdays. When the recurring event is parsed, the first week parses correctly. But for all subsequent weeks, Mondays are omitted.

I enabled debugging in the function that locates the next occurrence of an event and it looks like after the event on Wednesday, the EOP (end of period) value was being set to the following Monday but at midnight, so the event on Monday was out of the scope. When it continued in the loop, it began with Tuesday, so no Monday (other than the first Monday) was included in the list of recurrences.

The solution that we employed was this:

Changed line 367 in /opt/calendar/vendor/om/icalparser/src/Freq.php to read
return $this->findStartingPoint($offset, 1, false);

Original value was:
return $this->findStartingPoint($offset, 1);

I have no idea if that was the correct way to resolve it, or if this should be introduced as something permanent to the code base. But it's working for our specific situation.

Recurring event is set to freq=yearly, but there is no rrule with that

BEGIN:VEVENT
UID:111
DTSTAMP:20181123T192651Z
CATEGORIES;LANGUAGE=de-DE:Party
CONTACT:
DESCRIPTION:xxx
DTSTART;TZID=Europe/Berlin:20160415T210000
DTEND;TZID=Europe/Berlin:20160416T040000
LOCATION:xxx
RDATE;TZID=Europe/Berlin:20161216T210000
RDATE;TZID=Europe/Berlin:20161223T210000
RDATE;TZID=Europe/Berlin:20161230T210000
SEQUENCE:0
SUMMARY:xxx
END:VEVENT

From this event, these dates are generated:
20160415
20161216
20161223
20161230
20170415
20180415
20190415

This is not correct. This problem seems to be the default setting in Freq.php:

protected $rules = ['freq' => 'yearly', 'interval' => 1];

There is no yearly rule in this event.

Uncaught Error: Call to a member function sorted() on array

Hi,

When I use the foreach loop as described in the doc, I get that fatal Error

foreach ($cal->getEvents()->sorted() as $event) {

Uncaught Error: Call to a member function sorted() on array

If I remove the sorted part, the script is working but it seems there are confusions in the event Dates

foreach ($cal->getEvents() as $event) {
My php version is 7.4.27 and installed icalparser via composer this week.

What could I have missed?

Thank you for your Help!

Export single Event

Hey.. since it is possible to grab parsed informations of a single event out of an ICS-File with multiple events:
Maybe it is possible or easy to implement exporting single event as ICS file?

thx

freepbx ical parser error outlook.com calendar

The timezones used by outlook.com 's ical files aren't supported so it seems.

DateTimeZone::__construct(): Unknown or bad timezone ((UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna)
File:/var/www/html/admin/modules/calendar/vendor/om/icalparser/src/IcalParser.php:252

parseFile: failed to open stream: No such file or directory

File: icalparser/src/IcalParser.php
Line: 126
Function name: parseFile

The code is expected to throw exception on failing to open file. There is PHP warning instead with message: failed to open stream: No such file or directory.

OS: Ubuntu Server 14.04
PHP version: 5.5+

Two weekly recurrence rule does not function

In my Google calender two different weekly events are scheduled.
One event is on a tuesday every two weeks. The other event also but one week shifted. (Same starttime and endtime.)
So, effectively the events alternate every week.

When i use icalparser both events are shown every thuesday.
(Google calender shows the events correctly (alternating on tuesday).
Any idea whats going wrong?

Example of one event:
Thuesday event.txt

Installation instructions

Installed with composer:

  • Installing om/icalparser (v0.1.1): Downloading (100%)
    Writing lock file
    Generating autoload files

Copied the example to testi.php and:
PHP Fatal error: Class 'om\IcalParser' not found in /www/default/rislointra/testi.php on line 20

What else shoud be done? I am not familiar with composer at all, but the require_once dependency seems to be loaded since no error message on it.

Problem with reoccurring dates

Issue with RRULE:FREQ=WEEKLY;BYDAY=SU,MO,TU,WE,TH,FR

BEGIN:VCALENDAR
PRODID:-//Google Inc//Google Calendar 70.9054//EN
VERSION:2.0
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-CALNAME:Office Hours
X-WR-TIMEZONE:America/New_York
X-WR-CALDESC:
BEGIN:VTIMEZONE
TZID:America/Los_Angeles
X-LIC-LOCATION:America/Los_Angeles
BEGIN:DAYLIGHT
TZOFFSETFROM:-0800
TZOFFSETTO:-0700
TZNAME:PDT
DTSTART:19700308T020000
RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:-0700
TZOFFSETTO:-0800
TZNAME:PST
DTSTART:19701101T020000
RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
END:STANDARD
END:VTIMEZONE
BEGIN:VEVENT
DTSTART;TZID=America/Los_Angeles:20180506T100000
DTEND;TZID=America/Los_Angeles:20180506T103000
RRULE:FREQ=WEEKLY;BYDAY=SU,MO,TU,WE,TH,FR
DTSTAMP:20180722T165639Z
UID:[email protected]
CREATED:20180721T064200Z
DESCRIPTION:
LAST-MODIFIED:20180721T065236Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:Ok
TRANSP:OPAQUE
END:VEVENT
BEGIN:VEVENT
DTSTART;VALUE=DATE:20180129
DTEND;VALUE=DATE:20180130
DTSTAMP:20180722T165639Z
UID:[email protected]
CREATED:20180130T220521Z
DESCRIPTION:
LAST-MODIFIED:20180130T220555Z
LOCATION:
SEQUENCE:1
STATUS:CONFIRMED
SUMMARY:All Day
TRANSP:TRANSPARENT
END:VEVENT
END:VCALENDAR

In the rule above I have Sunday, Monday, Tuesday, Wednesday, Thursday, Friday.

However the result I get from icalparser skips Mondays (the even started ON a Monday)
image

I figured out that this is a bug in freq.php

If you debug Freq.php (turn $debug = true in method findNext). You'll see this

O: Mon, 03 Dec 2018 00:00:00 -0800
START: Mon, 03 Dec 2018 10:00:00 -0800
EOP: Mon, 10 Dec 2018 00:00:00 -0800
DAY: Sun, 09 Dec 2018 10:00:00 -0800 A: 1
DAY: Mon, 10 Dec 2018 10:00:00 -0800 A: 0
DAY: Tue, 04 Dec 2018 10:00:00 -0800 A: 1
DAY: Wed, 05 Dec 2018 10:00:00 -0800 A: 1
DAY: Thu, 06 Dec 2018 10:00:00 -0800 A: 1
DAY: Fri, 07 Dec 2018 10:00:00 -0800 A: 1
OK

Notice "DAY: Mon, 10 Dec 2018" is A: 0. Thats because the EOP (End of period) is set to 12:00am. On Monday the Event goes until 10:00:00. So it's outside the range of the EOP. However it shouldn't be. The EOP should be the same time as START (not the same date).

I was able to fix this by making sure the EOP time is set to the time of START (I didn't change the date though)

Freq.php Line 279:
Replace:
$eop = $this->findEndOfPeriod($offset);
with

		//EOP needs to have the same TIME as START ($t)
		$tO = new \DateTime('@'.$t, new \DateTimeZone('UTC'));

		$eop = $this->findEndOfPeriod($offset);
		$eopO = new \DateTime('@'.$eop, new \DateTimeZone('UTC'));
		$eopO->setTime($tO->format('H'),$tO->format('i'),$tO->format('s'));
		$eop = $eopO->getTimestamp();
		unset($eopO);
		unset($tO);

I still need to run through your unit tests to confirm this won't break anything

Multiple "CATEGORIES" sections

hey.. when i add multiple categories via thunderbird to my nextcloud caldav calendar, it is like:

CATEGORIES:Anruf
CATEGORIES:Besondere Gelegenheit
CATEGORIES:Feiertag
CATEGORIES:Online
CATEGORIES:Suppliers

$cal->getSortedEvents() just gets the last one.. only CATEGORIES:Suppliers is there

Timezone

How can you display the time in the correct time zone?

Error 500 on large ics file (1.9MB)

Hello,

I try to Parse a Google Calendar ICS file.

No problem with my own calendar as I barely use it, it's a small file.

But when I try with my Boss' calendar, I get a 500 server Error because of the large file (1.9MB).

I think I could increase php memory limit but I would like to find a more efficient way.

Is there a method to split the large file for example or another solution?

DateTimeZone::__construct(): Unknown or bad timezone

Issue: Invalid timezone error

Observations:

Two invalid timezone entries were encountered in our system:

  1. DateTimeZone::__construct(): Unknown or bad timezone (Argentina/Buenos_Aires)
  2. DateTimeZone::__construct(): Unknown or bad timezone (Indiana/Indianapolis)

Upon examining the IcalParser.php file, I noticed that the toTimezone function searches for a matching value within the windowsTimezones array. If it cannot find a match, it proceeds to use the $zone value directly. However, the subsequent operations involving new DateTimeZone($value) do not accept the value returned by this function. It seems that additional entries may need to be added to the windowsTimezones file.

Any help or guidance on resolving this issue would be greatly appreciated. Thank you in advance!

Yearly recurring events in January are not handled correctly

I think I found a bug: Yearly recurring events in January are not handled correctly, except for the first occurrence.

It's difficult to debug the code, but I think it's caused by the following line:

if ($imm > $offset && $imm <= $eop && ($_t == null || $imm < $_t)) {

						if ($imm > $offset && $imm <= $eop && ($_t == null || $imm < $_t)) {

If this is changed into:

						if ($imm >= $offset && $imm <= $eop && ($_t == null || $imm < $_t)) {

then it's working.

Shall I make a PR for this?

error when using example (T_ENCAPSED_AND_WHITESPACE)

Hello

I just tried to run the ical parser with the given example under PHP 5.3.17. However this results in a blank page and lots of messages like this in the logs:

[Mon Jun 01 14:59:52 2015] [error] [client 149.217.48.231] PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE in /srv/www/htdocs/news/include/IcalParser.php on line 92

Whats the problem here?

Best,
Thomas

Recurrency rule 'Every last ...day of the month' is not correctly processed.

I made an event in my Google calender with recurrency "Every last tuesday of the month". Starting at tuesday 28 november (for 6 times).
The output from the function parseFile is an array. The recurrences part is shown below.
[RECURRENCES] => Array(
[0] => DateTime Object ( [date] => 2023-11-28 20:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam)
[1] => DateTime Object ( [date] => 2023-12-26 20:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam)
[2] => DateTime Object ( [date] => 2024-01-23 20:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam)
[3] => DateTime Object ( [date] => 2024-02-20 20:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam)
[4] => DateTime Object ( [date] => 2024-03-19 20:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam)
[5] => DateTime Object ( [date] => 2024-04-16 20:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Amsterdam))

As you can see the dates are tuesdays but not last tuesdays!

I'am not a php-pro. So I cannot pinpoint the code thats causing this error.

Thanks in advance for your attention.
Wim Raaij

recurring meetings with single instance exception

When parsing recurring meetings it will detect a single meeting exception(occurrence) as a different recurring instance.

Here is an example sanitized ics file

https://gist.github.com/jasonheffner/eeb934d3edd29bc50ee40580e6890459

A single occurrence(exception) of a recurring meeting happens on 4/4/2017 at 3:30 - 4:30 EST which normally happens at 2:00 - 3:00 recurring. The code treats this as a separate recurring meeting and produces the following.

  • Thu, 06 Apr 2017 15:30:00 - 16:30:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 13 Apr 2017 15:30:00 - 16:30:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 20 Apr 2017 15:30:00 - 16:30:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 04 May 2017 15:30:00 - 16:30:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 11 May 2017 15:30:00 - 16:30:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 18 May 2017 15:30:00 - 16:30:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 20 Apr 2017 14:00:00 - 15:00:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 04 May 2017 14:00:00 - 15:00:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 18 May 2017 14:00:00 - 15:00:00 : Student Forecasting/ Advising Project Meeting
  • Thu, 11 May 2017 11:00:00 - 12:00:00 : Student Forecasting/ Advising Project Meeting
  • Wrong date format will trigger an uncatched exception

    If an ICS has wrong date for some eveent (like : DTEND;VALUE=DATE:20141225 ), DateTime constructor will trigger an exception.

    For the moment, this exception in un catched, and caused file parsing failure.

    I will submit a pull request to fix that.
    I propose to catch the exception, and set an empty value instead of the datetime object.

    Which fallback value seems better ? null, false, an empty datetime object ?

    Thank you and I will help :)

    Hello @OzzyCzech ,
    thank you for this great parser.
    I have tested it yesterday with different calendars and worked out some way of using.
    Even I experimented of array based reading of the calendar.
    Due there is no tutorial or wiki, I would kindly assist you here, furthermore Im proud to use code from someone who is from the same country like me ;)
    I will try to make some wiki page entries and demo code, even explanation of your php code with getsorted and getsortedreverse (what I really looked for ;) )

    Thank you

    Multiple ATTACH Instances

    When parsing a VEVENT that has multiple ATTACH instances, the ATTACH key is overwritten by each subsequent instance. To retain backwards compatibility, I would recommend adding a new key called ATTACHMENTS and making it an array of 1 or more values. See my pull request.

    add 'URL' ?

    Hi Roman,
    first, thanks for this useful Project !
    just a short note: I found one thing missing: URL specification for events.
    here is my modification:
    `diff --git a/src/IcalParser.php b/src/IcalParser.php
    index 9a91656..349e018 100644
    --- a/src/IcalParser.php
    +++ b/src/IcalParser.php
    @@ -247,10 +247,11 @@ class IcalParser {
    }

                //implement 4.3.11 Text ESCAPED-CHAR
    
    •           // added 'URL', 05.04.19 josswern
                $text_properties = [
                        'CALSCALE', 'METHOD', 'PRODID', 'VERSION', 'CATEGORIES', 'CLASS', 'COMMENT', 'DESCRIPTION'
                        , 'LOCATION', 'RESOURCES', 'STATUS', 'SUMMARY', 'TRANSP', 'TZID', 'TZNAME', 'CONTACT', 'RELATED-TO', 'UID'
      
    •                   , 'ACTION', 'REQUEST-STATUS'
      
    •                   , 'ACTION', 'REQUEST-STATUS','URL',
                ];
                if (in_array($key, $text_properties) || strpos($key, 'X-') === 0) {
                        if (is_array($value)) {
      

    `

    • maybe you can incorpoate that ?
      cheers
      Werner

    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.