Thanks to visit codestin.com
Credit goes to github.com

Skip to content
forked from simshaun/recurr

PHP library for working with recurrence rules (RRULE); meant to help with recurring calendar events.

License

Notifications You must be signed in to change notification settings

pborreli/recurr

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Recurr Build Status

Recurr is a PHP library for working with recurrence rules (RRULE) and converting them in to DateTime objects.

Recurr was developed as a precursor for a calendar with recurring events, and is heavily inspired by rrule.js.

Installation

Recurr is hosted on packagist, meaning you can install it with Composer.

Create a composer.json file

{
    "require": {
        "simshaun/recurr": "dev-master"
    }
}

Install composer and run it

wget http://getcomposer.org/composer.phar
php composer.phar install

(Optional) Autoload Recurr

require 'vendor/autoload.php';

Demo

$timezone    = 'America/New_York';
$startDate   = new \DateTime('2013-06-12 20:00:00', new \DateTimeZone($timezone));
$rule        = new \Recurr\RecurrenceRule('FREQ=MONTHLY;COUNT=5', $startDate, $timezone);
$transformer = new \Recurr\RecurrenceRuleTransformer($rule);

print_r($transformer->getComputedArray());

Warnings

  • Monthly recurring rules: If your start date is on the 29th, 30th, or 31st, Recurr will skip the months that have less than that number of days. This behavior is configurable:
$timezone    = 'America/New_York';
$startDate   = new \DateTime('2013-01-31 20:00:00', new \DateTimeZone($timezone));
$rule        = new \Recurr\RecurrenceRule('FREQ=MONTHLY;COUNT=5', $startDate, $timezone);
$transformer = new \Recurr\RecurrenceRuleTransformer($rule);

$transformerConfig = new \Recurr\TransformerConfig();
$transformerConfig->enableLastDayOfMonthFix();
$transformer->setTransformerConfig($transformerConfig);

print_r($transformer->getComputedArray());

/* Outputs:
 * 2013-01-31
 * 2013-02-28
 * 2013-03-31
 * 2013-04-30
 * 2013-05-31
 */

Contribute

Recurr is still in beta, and is most likely not 100% free of bugs. Feel free to comment or make pull requests. Please include tests with PRs.

License

Recurr is licensed under the MIT License. See the LICENSE file for details.

About

PHP library for working with recurrence rules (RRULE); meant to help with recurring calendar events.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%