1
0
mirror of https://github.com/rlanvin/php-rrule.git synced 2024-11-28 05:24:10 +01:00
This library offers a small, complete, and very fast, implementation of the recurrence rules documented in the iCalendar RFC. It is heavily based on python-dateutil.
Go to file
rlanvin d2384c1997 Adding interface to make RSet behave like RRule
Recurrence rules and a recurrence sets now share the same interface.
Also added isFinite() and isInfinite() methods, and improved
the implementation of RSet (ref #7)
2016-03-21 22:43:38 +02:00
src Adding interface to make RSet behave like RRule 2016-03-21 22:43:38 +02:00
tests Adding interface to make RSet behave like RRule 2016-03-21 22:43:38 +02:00
.gitignore Initial commit 2015-06-24 19:28:25 +03:00
.travis.yml Attempt to lower compatibility to PHP 5.3 2015-06-27 14:12:57 +03:00
CHANGELOG.md Using references for easier reading 2016-03-21 21:55:40 +02:00
composer.json Using PSR-4 autoloader instead of classmap 2016-03-15 18:46:31 +02:00
LICENSE Updating README, LICENSE and comments 2015-06-26 22:10:46 +03:00
phpunit.xml.dist Initial commit 2015-06-24 19:28:25 +03:00
README.md Add composer require command for a more streamlined install 2016-03-09 08:29:21 -06:00

RRULE for PHP

Lightweight and fast implementation of recurrence rules for PHP (RFC 5545), to easily work with recurring dates and events (such as in a calendar). This library is heavily based on python-dateutil.

Build Status

Basic example

use RRule\RRule;

$rrule = new RRule([
	'FREQ' => 'MONTHLY',
	'INTERVAL' => 1,
	'DTSTART' => '2015-06-01',
	'COUNT' => 6
]);

foreach ( $rrule as $occurrence ) {
	echo $occurrence->format('D d M Y'),"\n";
}

// will output:
// Mon 01 Jun 2015
// Wed 01 Jul 2015
// Sat 01 Aug 2015
// Tue 01 Sep 2015
// Thu 01 Oct 2015
// Sun 01 Nov 2015

echo $rrule->humanReadable(),"\n";
// monthly on the 1st of the month, starting from 01/06/2015, 6 times

Complete doc is available in the wiki.

Requirements

  • PHP >= 5.3
  • intl extension is recommended for humanReadable() but not strictly required

Installation

The recommended way is to install the lib through Composer.

Just add this to your composer.json file (change the version by the release you want, or use dev-master for the development version):

{
    "require": {
        "rlanvin/php-rrule": "1.*"
    }
}

Then run composer install or composer update.

Or just run composer require "rlanvin/php-rrule" "1.*" for it to be automatically installed and included in your composer.json

Now you can use the autoloader, and you will have access to the library:

<?php
require 'vendor/autoload.php';

Alternative method

You can just download src/RRule.php and require it.

However be sure to come back regulary and check for updates.

Documentation

Complete doc is available in the wiki.

Contribution

Feel free to contribute! Just create a new issue or a new pull request.

Note

I started this library because I wasn't happy with the existing implementations in PHP, so I thought it would be a good learning project to port the python-dateutil rrule implementation into PHP.

The Python lib was a bit difficult to understand because the algorithms are not commented and the variables are very opaque (I'm looking at you lno1wkst). I tried to comment and explain as much of the algorithm as possible in this PHP port, so feel free to check the code if you're interested.

The lib differs from the python version in various aspects, notably in the respect of the RFC. This version is a bit strictier and will not accept many non-compliant combinations of rule parts, that the python version otherwise accepts. There are also some additional features in this version.

License

This library is released under the MIT License.