Search by

adachsoft / recurrence

Arkadiusz Adach

Calculate and normalize one-time and repeating recurrence schedules with local-time and RFC 5545 semantics.

Package info

gitlab.com/a.adach/recurrence

Issues

pkg:composer/adachsoft/recurrence

Statistics

Installs: 6

Dependents: 1

Suggesters: 0

Stars: 0

v0.1.0 2026-11-22 12:46 UTC

This package is auto-updated.

Last update: 2026-11-22 11:46:50 UTC


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.