PHPackages                             thepublicgood/timewarp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. thepublicgood/timewarp

Abandoned → [eluceo/ical](/?search=eluceo%2Fical)ArchivedLibrary[Parsing &amp; Serialization](/categories/parsing)

thepublicgood/timewarp
======================

PHP Library for working with iCalendar objects

v0.3.1(5y ago)0507MITPHPPHP ^7.1.8

Since Jul 26Pushed 5y ago1 watchersCompare

[ Source](https://github.com/tpg/timewarp)[ Packagist](https://packagist.org/packages/thepublicgood/timewarp)[ RSS](/packages/thepublicgood-timewarp/feed)WikiDiscussions master Synced today

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

Timewarp
========

[](#timewarp)

[![Build Status](https://camo.githubusercontent.com/f6f9480de34b31a62bd7fd27baffcc2ea0ce1f52f7d2304bee36b213dc087f37/68747470733a2f2f7472617669732d63692e6f72672f7470672f74696d65776172702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/tpg/timewarp)[![Codacy Badge](https://camo.githubusercontent.com/e3cc6b363e15df1508a24725ceb15cd40c3d5c4ba9f1d746ea9a62d559404b76/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f3730323834306562303135653434396339386430633962336430636535393561)](https://app.codacy.com/app/makers/timewarp?utm_source=github.com&utm_medium=referral&utm_content=tpg/timewarp&utm_campaign=badger)[![GitHub License](https://camo.githubusercontent.com/c85185826eafd3f84e46e387f46906727e17595e0b26651e056a0e33e1dccf46/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7470672f74696d65776172702e737667)](https://camo.githubusercontent.com/c85185826eafd3f84e46e387f46906727e17595e0b26651e056a0e33e1dccf46/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7470672f74696d65776172702e737667)[![GitHub Release](https://camo.githubusercontent.com/c446894374fc8c51b4899dc03acd0dd9c0a4fd4b1366d883a3bceca1d2541c74/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7470672f74696d65776172702e737667)](https://camo.githubusercontent.com/c446894374fc8c51b4899dc03acd0dd9c0a4fd4b1366d883a3bceca1d2541c74/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7470672f74696d65776172702e737667)

Timewarp is simple library for dealing with iCalendar objects. The library attempts to adhere to RFC [5545](https://tools.ietf.org/html/rfc5545) and [5546](https://tools.ietf.org/html/rfc5546).

> There's a lot of features and requirements missing and I'll work on documentation as time allows. It might not be as up-to-date as it should be until a version 1.0 is complete, so I cannot make any promises as to the quality of the documentation. However I use Timewarp myself in a number of projects, so it does (and will) receive updates.

---

Installation
------------

[](#installation)

Timewarp can be installed with Composer:

```
composer require thepublicgood/timewarp

```

Or update your `composer.json` file with do a `composer update`:

```
{
    "require": {
        "thepublicgood/timewarp": "master"
    }
}
```

Usage
=====

[](#usage)

An iCalendar object is generally composed of a number of properties and calender components. A calendar object MUST contain at least one calendar component, and will often not contain more than one, although entirely possible.

Timewarp calendars can be created in one of two ways. Either create the calendar object first and add components to it, or create a calendar component and wrap it in a calendar object. You might find the later approach to be a little more semantic when working with a single component.

Calendar Objects
----------------

[](#calendar-objects)

Create a new calendar object by instantiating the `Calendar` class:

```
use TPG\Timewarp;

class CalendarController
{
    public function index()
    {
        $calendar = new Timewarp\Calendar();
    }
}
```

Add components to the calendar by calling the `addComponent` method and passing in an instance of a Timewarp component.

### Calendar Properties

[](#calendar-properties)

All calendars MUST include at least two properties. The first is a `Version` property. You won't need to add a `Version` property yourself as Timewarp will add it when you create a new `Calendar` object.

#### Product Identifier

[](#product-identifier)

You are required to add the product identifier to the calendar.

```
$calendar->addProperty(new Timewarp\Properties\ProdId($productId));
```

The product ID is meant to specify the product that created the iCalendar object, and MUST be globally unique. A common approach to product IDs, take a look at Formal Public Identifiers (ISO.9070.1991).

#### Method

[](#method)

You can specify a method on the calendar. The iCalendar spec does not define any values for the `METHOD` property, so whatever you pass here should have some meaning to your application.

```
$calendar->addProperty(new Timewarp\Properties\Method($method));
```

No other properties can be added directly to a calendar object and attempting to do so will result in a `FailedConformanceTestException`.

Creating events
---------------

[](#creating-events)

You can create a new event component by instantiating the `Components\Event` class:

```
use TPG\Timewarp;

class CalendarController
{
    public function index()
    {
        $event = new Timewarp\Components\Event();
    }
}
```

Properties can be added to the component through the `addProperty` method. The `appProperty` method returns the current object so it can be chained. The method accepts a single `Property` object which is any object that inherits from the `Property` class. Timewarp provides most of the standard properties in the `Timewarp\Properties` namespace.

```
$dtStart = new Timewarp\Properties\Start(new \DateTime('2019-01-01 13:30:00'));
$event->addProperty($dtStart)
    ->addProperty(new Timewarp\Properties\Description('New Years! Yeah!');
```

Add the event component to an existing calendar object:

```
$calendar->addComponent($event);
```

...or create a new calendar from the component:

```
$calendar = $event->getCalendar();
```

A place to start...
-------------------

[](#a-place-to-start)

```
$calendar = Timewarp\Calendar::event()->from(2018, 3, 1)->forHours(3);
```

Component Properties
--------------------

[](#component-properties)

Timewarp provides a class to represent each iCalender property. So the `DTSTART` property. so the `DTSTART` property is represented by the `Start` class, and the `DURATION` property is represented by the `Duration` class.

Many of the iCalendar properties can be added to any of the different components, although a few properties are component specific, and Timwarp will thow a `FailedConformanceTestException` if you try to add a property to component that doesn't support it.

### Attachment Property

[](#attachment-property)

An attachment is a representation of a document on a component. Attachments can be added to `Event`, `Todo`, `Journal` and `Alarm` components.

Unlike the other property classes, Timewarp provides two separate classes to represent attachments. The `UriAttachment` and `BinaryAttachment` properties.

```
// UriAttachment represents a URI to a file resource
$attachment = new Timewarp\Properties\UriAttachment('https://example.com/picture.png', 'image/png');

// While BinaryAttachment will base64 encode a file and include it in the component
$attachment = new Timewarp\Properties\BinaryAttachment($filePath);
```

`BinaryAttachment` will automatically determine the mime-type if a file is passed in. you can, however, pass in your own base64 encoded string and include the mime-type as the second parameter.

### Categories Property

[](#categories-property)

A category is a simple text string which can be used to categorize iCalendar components. The RFC 5545 document states that "categories are useful in searching for calendar components of a particular type".

The Categories property allow for multiple values, so you can pass in an array of values:

```
$category = new Timewarp\Properties\Categories(['APPOINTMENTS', 'EDUCATION']);
```

### Classification Property

[](#classification-property)

The classification property forms part of the general security within a calendar application. It allows the application to specify the accessability others have to the information in the object.

Timewarp allows one of three values to be set as the classification. `PUBLIC`, `PRIVATE` or `CONFIDENTIAL`. Timewarp provides these values as class constants as well:

```
$class = new Timewarp\Properties\Classification(Timewarp\Properties\Classification::PRIVATE);

// or...
$class = new Timewarp\Properties\Classification('PUBLIC');
```

### Comment Property

[](#comment-property)

A simple comment that can be included in the calendar object and provides information to the calendar user.

```
$comment = new Timewarp\Properties\Comment('Add a comment to a calendar object');
```

Calendar object lines should never exceed 75 octets. Comments will automatically be broken up across multiple lines as needed.

### Description Property

[](#description-property)

### Geographic Property

[](#geographic-property)

### Location Property

[](#location-property)

### Percent Complete Property

[](#percent-complete-property)

### Priority Property

[](#priority-property)

### Resources Property

[](#resources-property)

### Status Property

[](#status-property)

### Summary Property

[](#summary-property)

### Start Date

[](#start-date)

Represents the starting date and time of the component. This property can be added to `Event`, `Todo` and `FreeBusy` components.

The `Start` property accepts a standard PHP `DateTime` object:

```
$start = new Timewarp\Properties\Start(new \DateTime('2019-01-01 13:30:00'));

// Libraries like Carbon extend DateTime, so you can also do:
$start = new Timewarp\Properties\Start(Carbon::create(2019, 1, 1));
```

### End Date

[](#end-date)

The `End` property is exactly the same as the `Start` property, but represents when a component is supposed to end.

```
$end = new Timewarp\Properties\End(new \DateTime('2019-01-01 19:30:00'));
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~165 days

Total

5

Last Release

2185d ago

Major Versions

v0.2.1 → v1.x-dev2019-07-23

### Community

Maintainers

![](https://www.gravatar.com/avatar/89ea2dc12cd0a934de60705f8cfe47397095d842121b7d5f545dc9d1cee554ec?d=identicon)[warrickbayman](/maintainers/warrickbayman)

---

Top Contributors

[![codacy-badger](https://avatars.githubusercontent.com/u/23704769?v=4)](https://github.com/codacy-badger "codacy-badger (1 commits)")

---

Tags

calendardateicalendar-objectsicsphpphp7time

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/thepublicgood-timewarp/health.svg)

```
[![Health](https://phpackages.com/badges/thepublicgood-timewarp/health.svg)](https://phpackages.com/packages/thepublicgood-timewarp)
```

###  Alternatives

[spatie/laravel-sitemap

Create and generate sitemaps with ease

2.6k14.6M107](/packages/spatie-laravel-sitemap)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9738.8k](/packages/sauladam-shipment-tracker)[professional-wiki/edtf

PHP library to parse, represent and work with dates that follow the Extended Date/Time Format specification.

10432.1k4](/packages/professional-wiki-edtf)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
