Coder Social home page Coder Social logo

sg-icalendar's Introduction

A simple and fast iCal parser.
-------------------------------------------------------------------------------

http://github.com/fangel/SG-iCalendar
With massive help from http://github.com/tpruvot/PHP-iCal
and http://github.com/xonev/SG-iCalendar
-------------------------------------------------------------------------------

A simple example :
 $ical = new SG_iCalReader( "./basic.ics" );
 //or
 $ical = new SG_iCalReader( "http://example.com/calendar.ics" );
 foreach( $ical->getEvents() As $event ) {
   // Do stuff with the event $event
 }

To check unit tests with phpunit, goto tests/ directory and :
 phpunit AllTests
 phpunit helpers/FreqTest

-------------------------------------------------------------------------------
CHANGELOG :
-------------------------------------------------------------------------------

current (31 oct 2010)
 + ical RDATE support (added dates in a range)
 + RDATE and EXDATE arrays support

0.7.0 (30 oct 2010)
 + ical EXDATE support (excluded dates in a range)
 + $event->isWholeDay()
 + getAllOccurrences() for repeated events
 + implemented a cache for repeated events

0.6.0 (29 oct 2010)
 + Added demo based on fullcalendar
 + Added duration unit tests
 + Support of Recurrent events in query Between()
 * various fixes on actual (5) issues

-------------------------------------------------------------------------------
TODO :
-------------------------------------------------------------------------------

These iCal keywords are not supported for the moment :
 - RECURRENCE-ID : to move one event from a recurrence
 - EXRULE : to exclude multiple days by a complex rule

Also, multiple RRULE could be specified for an event,
but that is not the case for most calendar applications

-------------------------------------------------------------------------------
To get more information about ical format and rules :
see http://www.ietf.org/rfc/rfc2445.txt

sg-icalendar's People

Contributors

dantepfer avatar ecentinela avatar fangel avatar foaly-nr1 avatar tpruvot avatar xonev 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

Watchers

 avatar  avatar  avatar  avatar  avatar

sg-icalendar's Issues

Timezone ID issue.

Greetings. I'm trying to use this parser with Yii framework but a strange problem is happening. When i load the ics file, outside the framework project directory, i get the entire calendar displayed in the demo. But, when i try to load it within the framework, i get this error:

"date_default_timezone_set(): Timezone ID '/mozilla.org/20071231_1/Europe/London' is invalid"

the ics file is this one:
http://www.gulbenkian.pt/calendar/eventos.ics

PHP Warning SG_iCal_Freq.php

hello i've got 2 PHP Warning:
in_array() expects parameter 2 to be array, null given in SG_iCal_Freq.php on line 487
in_array() expects parameter 2 to be array, null given in SG_iCal_Freq.php on line 291

solution
if (is_array($this->excluded)) {
.....
}

best regards

Bug in SG_iCal_Freq

Hi, I found bug in helpers/SG_iCal_Freq.php in function findNext on line 264.

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

I think, second condition must be $imm <= $eop
so as it is wrong recurrence in some cases. For example there is RRULE:
"FREQ=WEEKLY;COUNT=5;INTERVAL=1;BYDAY=SU,MO"
and start date for occurence is
"2014-04-06 00:00:00" and end date
"2014-04-06 01:00:00".
So for this RRULE and this start date function getAllOccurrences() gives us results:
string(19) "2014-04-06 00:00:00"
string(19) "2014-04-13 00:00:00"
string(19) "2014-04-20 00:00:00"
string(19) "2014-04-27 00:00:00"
string(19) "2014-05-04 00:00:00"
So you can see, that all Mondays is fully ignored! (For BYDAY=SU,TU or SU,WE or any other day of week all works fine.) It is so, because condition
"$imm < $eop" is strict.
When I set "$imm <= $eop" all works fine for ;BYDAY=SU,MO also and Mondays walk into result array of occurrences.

Lost space character in SG_iCal_Line

Hi - it looks like the code to process SUMMARY lines in .ics calendar files that extend beyond one line has a bug. The bug manifests when the last character on the line is a space.So, the following SUMMARY from an ics file which has a last character as a space:
SUMMARY:England Football Internationals: World Cup 2010 Qualifier: England
v Ukraine
will produce ...Englandv Ukraine

When there isn't a space, it works fine, so:
SUMMARY:England Football Internationals: World Cup 2010 Qualifier: Kazakhst
an v England
will produce ...Kazakhstan v England correctly.

I don't know if other fields, such as DESCRIPTION has the same problem, but I guess if it calls the same function SG_iCal_Line __construct, then it will.

CC licence

Hi,

our plugin was delisted from wordpress.org as we use your library and your library licence is not gpl compatible.
We were wondering why you choose a CC licence and if we could do something to make your code gpl. Thanks in advance.

Webcal names are not corrected.

Calendar names are properly displayed in the legend but they are not properly displayed in the pick multiple area (they are displayed via their filename).

On line 182 of calendar_functions.php external calendars are simply named by their file name. When the calendar is parsed this should be corrected in the 'X-WR-CALNAME' case on line 414 of ical_parser.php. In this case $actual_calname is properly saved and used for the legend, however the $cal_displaynames is not being saved properly as according to what I have seen $cal_displaynames does not refer to anything.

SG_iCal_Duration throws undefined offset errors

I'm currently testing the library against a number of caldav servers. The OSAF server, Cosmo, creates durations as
DURATION:P17D
which creates PHP error messages "PHP Notice: Undefined offset: {n} in SG_iCal_Duration.php on line {m}

where n is usually 7,9,11 dependent upon the passed duration, whilst m is line 27.28.29 for the same reason.

FIX The fix is simple. Use isset() function around the array allocation. Fixed code below.

public function __construct( $duration ) {
    if( $duration{0} == 'P' || (($duration{0} == '+' || $duration{0} == '-') && $duration{1} == 'P') ) {
        preg_match('/P((\d+)W)?((\d+)D)?(T)?((\d+)H)?((\d+)M)?((\d+)S)?/', $duration, $matches);
        $results = array('weeks'=>isset($matches[2]) ? (int)$matches[2] : 0,
                        'days'=>isset($matches[4]) ? (int)$matches[4] : 0,
                        'hours'=>isset($matches[7]) ? (int)$matches[7] : 0,
                        'minutes'=>isset($matches[9]) ? (int)$matches[9] : 0,
                        'seconds'=>isset($matches[11]) ? (int)$matches[11] : 0);

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.