GithubHelp home page GithubHelp logo

peter279k / php-rrule Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rlanvin/php-rrule

0.0 2.0 0.0 289 KB

Lightweight and fast recurring dates library for PHP (RFC 5545)

License: Other

PHP 100.00%

php-rrule's Introduction

RRULE for PHP

Lightweight and fast implementation of recurrence rules for PHP (RRULE from RFC 5545), to easily calculate recurring/repeating dates and events (such as in a calendar). This library started as a port of python-dateutil.

Build Status Latest Stable Version Total Downloads

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'),", ";
}
// 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 documentation and more examples are 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.

Simply run composer require rlanvin/php-rrule for it to be automatically installed and included in your composer.json.

Alternatively, just add this to your composer.json file and then run composer install (you can replace 1.* by any version selector, or even dev-master for the latest development version).

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

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

require 'vendor/autoload.php';

Alternative method (not recommended)

  • Download the latest release
  • Put the files in a folder that is autoloaded, or include or require them

Documentation

Complete documentation is available in the wiki.

You will also find useful information in the RFC 5545 section 3.3.10.

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.

php-rrule's People

Contributors

rlanvin avatar shoresofnowhere avatar gordonzhao avatar antitoine avatar bkosborne avatar infostreams avatar gustavs-gutmanis avatar maccath avatar marcorivm avatar marvinrabe avatar mromero91 avatar rriverak avatar tjlytle avatar solinx avatar javidalkaruzi avatar peter279k avatar

Watchers

 avatar  avatar

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.