adachsoft / recurrence
Calculate and normalize one-time and repeating recurrence schedules with local-time and RFC 5545 semantics.
v0.1.0
2026-11-22 12:46 UTC
Requires
- php: ^8.3
- adachsoft/recurrence-contracts: ^0.1
Requires (Dev)
- adachsoft/php-code-style: ^0.7.3
- friendsofphp/php-cs-fixer: ^3.95
- phpstan/phpstan: ^2.3
- phpunit/phpunit: ^13.4
- rector/rector: ^2.8
- symplify/phpstan-rules: ^14.19
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
adachsoft/recurrence calculates occurrences for one-time and repeating schedules defined with adachsoft/recurrence-contracts. It supports hourly, daily, weekly, monthly, and yearly rules, with schedule evaluation in each rule's local time zone. It also normalizes rules to JSON-serializable data and back.
Features
- Find the next occurrence or list occurrences in a time range.
- Support recurrence end conditions, exclusions, additions, and calendar selectors.
- Handle daylight-saving transitions for local-time schedules.
- Extend calculation and normalization with custom rule handlers.
Requirements and installation
Requires PHP 8.3 or later.
composer require adachsoft/recurrence
Usage
<?php
declare(strict_types=1);
use AdachSoft\Recurrence\RecurrenceFactory;
use AdachSoft\RecurrenceContracts\Rule\OneTimeRuleDto;
use DateTimeImmutable;
use DateTimeZone;
$timezone = new DateTimeZone('Europe/Warsaw');
$rule = new OneTimeRuleDto(
at: new DateTimeImmutable('2026-11-22 17:00:00', $timezone),
timezone: $timezone,
);
$calculator = RecurrenceFactory::createCalculator();
$nextOccurrence = $calculator->nextAfter(
$rule,
new DateTimeImmutable('2026-11-22 16:59:59', $timezone),
);
nextAfter() uses an exclusive lower boundary. between($rule, $from, $to) returns occurrences in the half-open interval [$from, $to). See usage examples for repeating rules and normalization.