The missing PHP 5.3+ calendar management library.



Build Status Scrutinizer Code Quality Code Coverage SensioLabsInsight

CalendR is an Object Oriented Calendar management library on top of PHP5.3+ Date objects. You can use it to deal with all your needs about calendars and events.

Complete documentation

Complete documentation is available here.


CalendR is hosted on packagist, you can install it with composer.

Create a composer.json file

        "require": {
            "yohang/calendr": "^1.1"

Install composer and run it

    php composer.phar install

(Optional) Autoload CalendR

    require 'vendor/autoload.php';


Calendar is open to contributions. Merging delays can vary depending to my free time, but always be welcome.


CalendR is licensed under the MIT License - see the LICENSE file for details

  • [WIP] Refactor period instantiation to manage alternate period classes

    [WIP] Refactor period instantiation to manage alternate period classes

    TODO list :

    • [x] Implement a factory class
    • [x] Use the Symfony option resolver to manage options (class names, first weekday)
    • [x] Remove all period instantiations and replace by factory calls
    • [ ] Enhance tests code coverage
    • [ ] Refactor
    • [x] Bump version to 1.1
    • [ ] Rewrite obsolete parts of documentation
    • [ ] Review, review and review
    opened by yohang 13
  • enable use of alternate period classes

    enable use of alternate period classes

    I need an alternate Week that only iterates over weekdays (that is, excluding Saturday and Sunday). I thought perhaps a more general solution would permit others to address their own needs to integrate alternate period classes.

    This PR offers the ability to supply the names of alternate 'dayClass', 'weekClass', 'monthClass' and/or 'yearClass' in an associative array:

    -- as a third parameter to the constructors of the existing Week, Month and Year classes (so that they use any specified alternate period in their iterators and the Days array in the case of Month.

    -- as the parameter to Calendar::setClasses.

    opened by ovgray 10
  • Option to start Week period on Sunday and end on Saturday

    Option to start Week period on Sunday and end on Saturday

    I do have some code implementing feature request from issue #8, but I am not very happy about it. It adds a static variable $firstWeekday to the Calendar class that one can modify before making any other object or calling a method.

    One should add some tests as this is a large change in calendar handling. Sorry about the code drop like this but it may be more useful than continue to keep it for myself.

    opened by grakic 10
  • February ends in March

    February ends in March

    This is a dump of February 2015:

    Month {#2306 ▼
      -current: null
      #begin: DateTime {#2288 ▼
        +"date": "2015-02-01 00:00:00"
        +"timezone_type": 3
        +"timezone": "Europe/Rome"
      #end: DateTime {#2295 ▼
        +"date": "2015-03-01 00:00:00"
        +"timezone_type": 3
        +"timezone": "Europe/Rome"
      #firstWeekday: 1

    I'd expect to see it ending 2015-02-28, not 2015-03-01.

    opened by garak 8
  • enable use of alternate period classes

    enable use of alternate period classes

    Another attempt at adding this functionality. The firstweekday numeric parameter is replaced with an options array parameter than can include a 'first_day' numeric element to change the week's first day from the default of Monday, and can also specify the names of one or more alternate period classes to use in place of Day, Week, Month, Year and/or Range.

    opened by ovgray 8
  • "period" isn't really correct


    Period doesn't have the same meaning in English and in French. Here is my best example:

    opened by willdurand 8
  • Add Support for Time Periods

    Add Support for Time Periods

    Time Periods

    • Created the classes required for the time periods Hour, Minute and Second. I can't think of any situation where seconds would actually be needed, but might as well have the complete set.
    • Update the Day period class to extend the \Iterator interface and provides each hour of the day upon iteration. Iterating over hours gives minutes and minutes gives seconds, as would be expected.
    • Update the Calendar and Factory classes to add new createPeriod() helper methods. They are also now defined in the FactoryInterface.

    Strict Dates

    • Create new option called strict_dates (default: false).
    • Update isValid() static methods, return false if the supplied \DateTime object is not at the very beginning of the date/time period.
    • If strict_dates is true, then a NotAPeriod exception is thrown from the constructor of the chosen period class when isValid() returns false.
    • If strict_dates is false, then do not validate the \DateTime object; automatically set the begin date to the beginning of the date/time period.
    • Create helper methods getStrictDates() and setStrictDates() in the Calendar and Factory classes (has not been added to the FactoryInterface).

    Strict Dates: Example

    $date = new \DateTime('2014-05-11 17:23:49');
    $factory = new \CalendR\Calendar;
    $month = new \CalendR\Period\Month($date, $factory);
    // A NotAMonth exception will be thrown.
    $month = new \CalendR\Period\Month($date, $factory);
    // The date returned from $month->getBegin() has been set to '2014-05-01 00:00:00'.

    Unit Tests

    All changes have 100% code coverage with unit tests which pass on Travis CI.

    opened by zanbaldwin 7
  • added Range class to accomodate for custom date/time ranges

    added Range class to accomodate for custom date/time ranges

    Single it is sometimes necessary to work with custom date/time ranges, I've added the Range class. Possibly, this could even be used as a base class for the other period classes, but I didn't include that in this pull request as it's definitely another change.

    opened by skoop 7
  • allow use of alternate Factory that implements FactoryInterface.

    allow use of alternate Factory that implements FactoryInterface.

    This PR modifies the present alternate-periods branch to allow use of alternate Factory that implements a new FactoryInterface, rather than having to extend CalendR\Period\Factory as it would with the current. It also moves the alternate period creation logic used by Calendar.php back to Calendar.php from Period/Factory.php, to simplify the Factory Interface. FactoryTest is modified to reflect these changes.

    I have not changed the phpdoc "@return" statements in Factory and elsewhere that assume that FactoryInterface methods return objects that extend CalendR\Period\ objects. I note that the AlternatePeriodsTest only verifies that the code will handle alternate period objects that extend those objects.

    It might be useful to permit alternate period objects that implement PeriodInterface (or, better, an Interface specific to Year, Month, Week, Day and Range objects) without having to extend the existing objects.

    If AlternatePeriodsTest reflects what you consider to be the required behavior of any Year, Month, Week, Day or Range object, then I could work out the interfaces from that.

    opened by ovgray 5
  • set first weekday

    set first weekday

    When calling $factory->setFirstWeekday() depending on current month first day, the class can generate an error.

    For example, trying to set first week day as Thursday on May 2013, via: $factory->setFirstWeekday(4)

    generates this: Fatal error: Uncaught exception 'Exception' with message 'DateInterval::__construct() [dateinterval.--construct]: Unknown or bad format (P-1D)' in ../vendor/yohang/calendr/src/CalendR/Period/Month.php:84

    opened by dragosperca 5
  • Event repositories can't be properly added with Symfony2 & Doctrine2

    Event repositories can't be properly added with Symfony2 & Doctrine2

    It's the second time I'm using Calendr for two different projects and I still get this error :

    Capture d e cran 2013-04-01 a 17 26 08

    The first time I used Calendr I had a PHP 5.4 server so I could use traits. My repository was declared as your first example code. To avoid the above error, I just added implements ProviderInterface to the EventRepository declaration and it was done.

    Now my server is under PHP 5.3 so I'm using the second way provided on the doc. But, using this second way doesn't provides all the methods required by ProviderInterface and, at this point, I'm stuck…

    opened by nesk 4
  • CalendR\Event\Exception\NoProviderFound:


            $factory = new \CalendR\Calendar;
            $month = $factory->getMonth(2020, 6);
            $events = $factory->getEvents($month);

    CalendR\Event\Exception\NoProviderFound: in file /home/wwwroot/ on line 68

    opened by 734918601 1
  • [FEATURE] Add data property to Event

    [FEATURE] Add data property to Event

    Hi all!

    I'm working with this library for a while (It works like a charm BTW), and I really missing what I think is a good new feature.

    The default Event model, does not have the possibility to hold a "data" (Where data is whatever you need, it could be an object, an array or a primitive), and you always have to extend default Entity to include your custom data.

    While i think this is good for advanced use cases, i think for simple use cases, having a "bag" where store whatever you need (a title, a status, or even an array with more complex data) without having to extend the default model would be perfect.

    I don't know what you think, if you agree I can work on a pull request.

    Thanks you for your work

    opened by juanmiguelbesada 1
  • Boilerplate code not working

    Boilerplate code not working

    Is this app still working with php 7 and Laravel 5.8?

    Because non of the site's bolierplate code is working.

    I cannot biuld the calendar, it only renders the day names, Mon to Fri repeteadly.


    opened by marcosdipaolo 3
  • Wrong return types in Calendar

    Wrong return types in Calendar

    Calendar class uses PeriodInterface as return type for getYear, getMonth, getWeek. Such method should return, respectively, Year, Month, Week, that are implementing \Iterator. With the current code, a call to foreach (new Calendar)->getMonth() is marked as invalid by phpstorm ("Can not iterate PeriodInterface").

    opened by garak 1
ReCalendar - highly customizable calendar for ReMarkable tablets

ReCalendar Highly customizable calendar for ReMarkable tablets ReCalendar allows you to generate your own, personalized calendar using PHP and the mPD

Igor Klimer 172 Oct 17, 2022
Display a calendar of commits from public GitHub repositories

commit-calendar Display a list of dates and commits from public GitHub repositories. You will display the list in the terminal, and you can choose to

Erika Gili 5 Jul 23, 2021
This helps with public holiday info using google calendar api

Public Holiday This package uses the Google Calendar API to fetch public holidays. The data always comes with 3 years data; the previous year, the cur

Temitope Olotin 5 Jul 13, 2022
Flexible Calendar for Laravel 4

Laravel 4 Calendar Flexible Calendar for Laravel 4, supports Month, Week and Day Views and multiple events per date. To change the view type dynamical

null 59 Dec 24, 2022
📆 Calendar app for Nextcloud

Nextcloud Calendar A calendar app for Nextcloud. Easily sync events from various devices with your Nextcloud and edit them online. ?? ?? Why is this s

Nextcloud 801 Dec 29, 2022
Manage events on a Google Calendar

Manage events on a Google Calendar This package makes working with a Google Calendar a breeze. Once it has been set up you can do these things: use Sp

Spatie 1k Dec 31, 2022
A package which provides a monthly calendar with days and events depending on given months and events.

A package which provides a monthly calendar with days and events depending on given months and events. This is where your description should go. Try a

MichaB 6 Nov 1, 2022
TeamCal Neo is a web application of a day-based calendar

TeamCal Neo is a web application of a day-based calendar. It's generic purpose is the absence and event management of project teams, music bands and other groups needing a scheduler that focusses on days.

George Lewe 3 Nov 15, 2022
Simple Event/Calendar

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files

TolisM 2 Feb 1, 2022
Laravel 9 & React Event Calendar

###Event Calendar ##Projeyi docker üzerinde ayağa kaldırma #Acount Service accountService klasörü içine girerek docker-compose up --build komutu ile a

Muhammed Mustafa Bulut 4 Apr 19, 2022
The easy PHP Library for calculating holidays

Introduction Yasumi (Japanese for 'Holiday'「休み」) is the easy PHP library that helps you retrieve the dates and names of holidays and other special cel

AzuyaLabs 926 Dec 29, 2022
This library helps PHP users to convert and using Jalali DateTime format

Easy Jalali for PHP V1.0.0 Jalali calendar converter for Persian users in Iran, Afghanistan and other countries that use Jalali calendar. Very thanks

Majid J 3 Mar 20, 2022
A standalone DateTime library originally based off of Carbon

CakePHP Chronos Chronos aims to be a drop-in replacement for nesbot/carbon. It focuses on providing immutable date/datetime objects. Immutable objects

CakePHP 1.3k Jan 1, 2023
A simple PHP API extension for DateTime.

Carbon An international PHP extension for DateTime. <?php use Carbon\Carbon; printf("Right now is %s", Carbon::now()->toDat

Brian Nesbitt 16k Dec 30, 2022
Parse, validate, manipulate, and display dates in PHP w/ i18n support. Inspired by moment.js

Support I am a dad now for the last 1,5 years and that clearly shows in being on time with merging PRs or pushing this package further. Time is the bi

Tino Ehrich 944 Dec 21, 2022
Date Manager PHP Class

Date Manager PHP Class Date Manager Version 1.0.0 PHP class for date management, for example converting solar date to gregorian date and vice versa. C

Alireza Tolouei 2 Dec 21, 2021
CRON for PHP: Calculate the next or previous run date and determine if a CRON expression is due

The PHP cron expression parser can parse a CRON expression, determine if it is due to run, calculate the next run date of the expression, and calculate the previous run date of the expression. You can calculate dates far into the future or past by skipping n number of matching dates.

Chris Tankersley 4.3k Jan 9, 2023
Parse and validate crontab expressions in PHP

Standard (V7) compliant crontab expression parser/validator with support for time zones; see "man 5 crontab" for possible expressions.

René Pollesch 42 Dec 14, 2022
iCal-creator for PHP - This package offers an abstraction layer for creating iCalendars files

This package offers an abstraction layer for creating iCalendars files. By using this PHP package, you can create *.ics files without the knowledge of the underling format. The output itself will follow RFC 5545 as good as possible.

Markus Poerschke 1k Dec 23, 2022