PHPackages                             tivus/yearly-timespan - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tivus/yearly-timespan

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tivus/yearly-timespan
=====================

yearly timspans, timelines, sql-friendly

v2.1.0(3y ago)21.3k↓50%MITPHPPHP &gt;=8.0

Since Apr 21Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/schuhwerk/yearly-timespan-php)[ Packagist](https://packagist.org/packages/tivus/yearly-timespan)[ RSS](/packages/tivus-yearly-timespan/feed)WikiDiscussions master Synced 1mo ago

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

Collection of PHP classes to work with yearly repeating timespans.

Heavily using [smhg](https://github.com/smhg/)s [date-timespan](https://github.com/smhg/date-timespan-php).

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

[](#installation)

```
composer require tivus/yearly-timespan dev-master
```

Classes
-------

[](#classes)

The examples shown here are additive (you need the previous ones for the later ones to work).

### Yearly Date

[](#yearly-date)

Extends the DateTime object. The year is set to 0.

```
    use Timespan\Timespan;
    use Yearly_Timespan\Yearly_Date;
    use Yearly_Timespan\Yearly_Timespan;

    $july = Yearly_Date::createFromFormat( 'd.m', '15.07' );
    $feb  = Yearly_Date::createFromFormat( 'd.m', '04.02' );
```

### Yearly Timespan

[](#yearly-timespan)

Extends the [smgh/timespan Class](https://github.com/smhg/date-timespan-php#timespan)

```
    $winter_term = new Yearly_Timespan(
        $july, // start, Yearly_Timespan object.
        $feb, // end. Yearly_Timespan object.
        'Winterterm', // name.
        'Term' // type.
    );
    $summer_term = new Yearly_Timespan(
        $feb,
        $july,
        'Summerterm',
        'Term'
    );

    // cast to a Timespan (with a name and type)
    $current_winter_term = $winter_term->cast_to_year( new \DateTime() );

    //check if a (regular) Date is contained by a Yearly_Timespan.
    if ( $winter_term->contains( \DateTime::createFromFormat( 'd.m.Y', '04.02.2019' ))) {
        echo '04.02.2019 is in the Winterterm. ';
    }

    // check if a (regular) Timespan is overlapped by a Yearly_Timespan.
    $project_week = new Timespan(
        \DateTime::createFromFormat( 'd.m.Y', '14.01.2019' ),
        \DateTime::createFromFormat( 'd.m.Y', '18.01.2019' )
    );

    if ( $winter_term->overlaps( $project_week ) ){
        echo 'The Projekt Week overlaps the Winterterm. ';
    }
```

### Yearly Timespan Collection

[](#yearly-timespan-collection)

```
    // Create a collection of Yearly_Timespans.
    $yearly_collection = new Yearly_Timespan_Collection();

    // Add Yearly_Timespans to the Collection.
    $yearly_collection[] = $winter_term;
    $yearly_collection[] = $summer_term;

    // Select a Yearly_Timespan (Winterterm in this case) and cast it to a year.
    $current_term = $yearly_collection->select( new DateTime('2020-01-01') )->get();

    // Get the timespan (not yearly) for the Summerterm 2020.
    $next_term = $yearly_collection->next()->get();

    // Create a collection of timespans (not yearly).
    $timespan_collection   = new \Timespan\Collection([
        new Timespan( new DateTime( '2015-02-02' ), new DateTime( '2015-07-06' ) ),
        new Timespan( new DateTime( '2016-06-02' ), new DateTime( '2017-04-06' ) )
    ]);

    /**
     * Create an array of specific timespans (form the yearly ones) that overlap our new $timespan_collection.
     * The new \Timespan\Collection Object ($navigation) has a data attribute
     * that references all Timespans (from the $timespan_collection)
     * (via an array index), that overlap the newliy create specific timespans ( $navigation ).
     */
    $navigation = $yearly_collection->group_timespans_by_collection( $timespan_collection );

    // Get an array of summerterms (specific timespans, not yearly ones) that overlap the given timespan.
    $many_terms = $yearly_collection->filter('any', 'Summerterm')->make_all_timespans_between(
        new Timespan(
            new DateTime('1990-01-01'),
            new DateTime('2010-01-01')
        )
    );
```

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance56

Moderate activity, may be stable

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity63

Established project with proven stability

 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 ~539 days

Total

3

Last Release

1134d ago

Major Versions

v1.0.0 → v2.0.02023-04-01

PHP version history (3 changes)v1.0.0PHP &gt;=5.6

v2.0.0PHP &gt;=8.1

v2.1.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/aebe77094076091be8fa744783ffd22647e3a24f64828308a0b4966026e7041c?d=identicon)[schuhwerk](/maintainers/schuhwerk)

---

Top Contributors

[![schuhwerk](https://avatars.githubusercontent.com/u/865652?v=4)](https://github.com/schuhwerk "schuhwerk (13 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tivus-yearly-timespan/health.svg)

```
[![Health](https://phpackages.com/badges/tivus-yearly-timespan/health.svg)](https://phpackages.com/packages/tivus-yearly-timespan)
```

###  Alternatives

[virusphp/bridging-bpjs

Service Briding Bpjs

413.8k](/packages/virusphp-bridging-bpjs)[mage2pro/currency-format

The «Price Format» extension for Magento 2

215.9k](/packages/mage2pro-currency-format)[hiqdev/hipanel-module-finance

Finance module for HiPanel

1116.9k1](/packages/hiqdev-hipanel-module-finance)

PHPackages © 2026

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