{"id":21467435,"url":"https://github.com/elusivecodes/fyreperiod","last_synced_at":"2025-09-15T09:09:25.475Z","repository":{"id":62550219,"uuid":"497275898","full_name":"elusivecodes/FyrePeriod","owner":"elusivecodes","description":"FyrePeriod is a free, open-source date period library for PHP.","archived":false,"fork":false,"pushed_at":"2024-10-22T10:09:50.000Z","size":142,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-23T09:38:45.574Z","etag":null,"topics":["date","period","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elusivecodes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-28T09:45:37.000Z","updated_at":"2024-10-22T10:09:05.000Z","dependencies_parsed_at":"2024-06-24T13:37:57.478Z","dependency_job_id":"66f5297a-55d3-4cb5-bf35-0d27f6c39edd","html_url":"https://github.com/elusivecodes/FyrePeriod","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePeriod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePeriod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePeriod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elusivecodes%2FFyrePeriod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elusivecodes","download_url":"https://codeload.github.com/elusivecodes/FyrePeriod/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226017524,"owners_count":17560531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["date","period","php"],"created_at":"2024-11-23T08:18:07.110Z","updated_at":"2024-11-23T08:18:07.756Z","avatar_url":"https://github.com/elusivecodes.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# FyrePeriod\r\n\r\n**FyrePeriod** is a free, open-source date period library for *PHP*.\r\n\r\n\r\n## Table Of Contents\r\n- [Installation](#installation)\r\n- [Periods](#periods)\r\n- [Period Collections](#period-collections)\r\n\r\n\r\n\r\n## Installation\r\n\r\n**Using Composer**\r\n\r\n```\r\ncomposer require fyre/period\r\n```\r\n\r\n\r\n## Periods\r\n\r\n```php\r\nuse Fyre\\Period\\Period;\r\n```\r\n\r\n- `$start` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) or string representing the start date.\r\n- `$end` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) or string representing the end date.\r\n- `$granularity` is a string representing the granularity, and can be one of either \"*year*\", \"*month*\", \"*day*\", \"*hour*\", \"*minute*\" or \"*second*\", and will default to \"*day*\".\r\n- `$excludeBoundaries` is a string representing the excluded boundaries, and can be one of either \"*none*\", \"*start*\", \"*end*\" or \"*both*\", and will default to \"*none*\".\r\n\r\n```php\r\n$period = new Period($start, $end, $granularity, $excludeBoundaries);\r\n```\r\n\r\nThe *Period* is an implementation of an *Iterator* and can be used in a foreach loop.\r\n\r\n```php\r\nforeach ($period AS $date) { }\r\n```\r\n\r\n**Contains**\r\n\r\nDetermine whether this period contains another *Period*.\r\n\r\n- `$other` is the *Period* to compare against.\r\n\r\n```php\r\n$contains = $period-\u003econtains($other);\r\n```\r\n\r\n**Diff Symmetric**\r\n\r\nGet the symmetric difference between the periods.\r\n\r\n- `$other` is the *Period* to compare against.\r\n\r\n```php\r\n$diffSymmetric = $period-\u003ediffSymmetric($other);\r\n```\r\n\r\nThis method will return a new [*PeriodCollection*](#period-collections).\r\n\r\n**End**\r\n\r\nGet the end date.\r\n\r\n```php\r\n$end = $period-\u003eend();\r\n```\r\n\r\nThis method will return a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).\r\n\r\n**End Equals**\r\n\r\nDetermine whether this period ends on a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$endEquals = $period-\u003eendEquals($date);\r\n```\r\n\r\n**Ends After**\r\n\r\nDetermine whether this period ends after a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$endsAfter = $period-\u003eendsAfter($date);\r\n```\r\n\r\n**Ends After Or Equals**\r\n\r\nDetermine whether this period ends on or after a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$endsAfterOrEquals = $period-\u003eendsAfterOrEquals($date);\r\n```\r\n\r\n**Ends Before**\r\n\r\nDetermine whether this period ends before a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$endsBefore = $period-\u003eendsBefore($date);\r\n```\r\n\r\n**Ends Before Or Equals**\r\n\r\nDetermine whether this period ends on or before a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$endsBeforeOrEquals = $period-\u003eendsBeforeOrEquals($date);\r\n```\r\n\r\n**Equals**\r\n\r\nDetermine whether this period equals another Period.\r\n\r\n- `$other` is the *Period* to compare against.\r\n\r\n```php\r\n$equals = $period-\u003eequals($other);\r\n```\r\n\r\n**Gap**\r\n\r\nGet the gap between the periods.\r\n\r\n- `$other` is the *Period* to compare against.\r\n\r\n```php\r\n$gap = $period-\u003egap($other);\r\n```\r\n\r\nThis method will return a new *Period*, or *null* if there's no gap.\r\n\r\n**Granularity**\r\n\r\nGet the granularity.\r\n\r\n```php\r\n$granularity = $period-\u003egranularity();\r\n```\r\n\r\n**Included End**\r\n\r\nGet the included end date.\r\n\r\n```php\r\n$includedEnd = $period-\u003eincludedEnd();\r\n```\r\n\r\nThis method will return a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).\r\n\r\n**Included Start**\r\n\r\nGet the included start date.\r\n\r\n```php\r\n$includedStart = $period-\u003eincludedStart();\r\n```\r\n\r\nThis method will return a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).\r\n\r\n**Includes End**\r\n\r\nDetermine whether the Period includes the end date.\r\n\r\n```php\r\n$includesEnd = $period-\u003eincludesEnd();\r\n```\r\n\r\n**Includes**\r\n\r\nDetermine whether this period includes a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$includes = $period-\u003eincludes($date);\r\n```\r\n\r\n**Includes Start**\r\n\r\nDetermine whether the Period includes the start date.\r\n\r\n```php\r\n$includesStart = $period-\u003eincludesStart();\r\n```\r\n\r\n**Length**\r\n\r\nGet the length of the period.\r\n\r\n```php\r\n$length = $period-\u003elength();\r\n```\r\n\r\n**Overlap**\r\n\r\nGet the overlap of the periods.\r\n\r\n- `$other` is the *Period* to compare against.\r\n\r\n```php\r\n$overlap = $period-\u003eoverlap($other);\r\n```\r\n\r\nThis method will return a new *Period*, or *null* if there's no overlap.\r\n\r\n**Overlap All**\r\n\r\nGet the overlap of all the periods.\r\n\r\n```php\r\n$overlapAll = $period-\u003eoverlapAll(...$others);\r\n```\r\n\r\nThis method will return a new *Period*, or *null* if there's no overlap.\r\n\r\n**Overlap Any**\r\n\r\nGet the overlaps of any of the periods.\r\n\r\n```php\r\n$overlapAny = $period-\u003eoverlapAny(...$others);\r\n```\r\n\r\nThis method will return a new [*PeriodCollection*](#period-collections).\r\n\r\n**Overlaps With**\r\n\r\nDetermine whether this period overlaps with another Period.\r\n\r\n- `$other` is the *Period* to compare against.\r\n\r\n```php\r\n$overlapsWith = $period-\u003eoverlapsWith($other);\r\n```\r\n\r\n**Renew**\r\n\r\nCreate a new period with the same length after this period.\r\n\r\n```php\r\n$renewed = $period-\u003erenew();\r\n```\r\n\r\nThis method will return a new *Period*.\r\n\r\n**Start**\r\n\r\nGet the start date.\r\n\r\n```php\r\n$start = $period-\u003estart();\r\n```\r\n\r\nThis method will return a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).\r\n\r\n**Start Equals**\r\n\r\nDetermine whether this period starts on a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$startEquals = $period-\u003estartEquals($date);\r\n```\r\n\r\n**Starts After**\r\n\r\nDetermine whether this period starts after a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$startsAfter = $period-\u003estartsAfter($date);\r\n```\r\n\r\n**Starts After Or Equals**\r\n\r\nDetermine whether this period starts on or after a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$startsAfterOrEquals = $period-\u003estartsAfterOrEquals($date);\r\n```\r\n\r\n**Starts Before**\r\n\r\nDetermine whether this period starts before a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$startsBefore = $period-\u003estartsBefore($date);\r\n```\r\n\r\n**Starts Before Or Equals**\r\n\r\nDetermine whether this period starts on or before a given date.\r\n\r\n- `$date` is the [*DateTime*](https://github.com/elusivecodes/FyreDateTime) to compare against.\r\n\r\n```php\r\n$startsBeforeOrEquals = $period-\u003estartsBeforeOrEquals($date);\r\n```\r\n\r\n**Subtract**\r\n\r\nGet the inverse overlap of the periods.\r\n\r\n- `$other` is the *Period* to compare against.\r\n\r\n```php\r\n$subtract = $period-\u003esubtract($other);\r\n```\r\n\r\nThis method will return a new [*PeriodCollection*](#period-collections).\r\n\r\n**Subtract All**\r\n\r\nGet the inverse overlap of all periods.\r\n\r\n```php\r\n$subtractAll = $period-\u003esubtractAll(...$others);\r\n```\r\n\r\nThis method will return a new [*PeriodCollection*](#period-collections).\r\n\r\n**Touches**\r\n\r\nDetermine whether this period touches another Period.\r\n\r\n- `$other` is the *Period* to compare against.\r\n\r\n```php\r\n$touches = $period-\u003etouches($other);\r\n```\r\n\r\n\r\n## Period Collections\r\n\r\n```php\r\nuse Fyre\\Period\\PeriodCollection;\r\n```\r\n\r\nAll arguments supplied will be used as periods for the collection.\r\n\r\n```php\r\n$periodCollection = new PeriodCollection(...$periods);\r\n```\r\n\r\nThe *PeriodCollection* is an implementation of an *Iterator* and can be used in a foreach loop.\r\n\r\n```php\r\nforeach ($periodCollection AS $period) { }\r\n```\r\n\r\n**Add**\r\n\r\nAdd periods to the collection.\r\n\r\nAll arguments supplied will be used as periods to add to the collection.\r\n\r\n```php\r\n$added = $periodCollection-\u003eadd(...$periods);\r\n```\r\n\r\nThis method will return a new *PeriodCollection*.\r\n\r\n**Boundaries**\r\n\r\nGet the boundaries of the collection.\r\n\r\n```php\r\n$boundaries = $periodCollection-\u003eboundaries();\r\n```\r\n\r\nThis method will return a new [*Period*](#periods), or *null* if the collection is empty.\r\n\r\n**Gaps**\r\n\r\nGet the the gaps between the periods in the collection.\r\n\r\n```php\r\n$gaps = $periodCollection-\u003egaps();\r\n```\r\n\r\nThis method will return a new *PeriodCollection*.\r\n\r\n**Intersect**\r\n\r\nIntersect a period with every period in the collection.\r\n\r\n- `$period` is the [*Period*](#periods) to compare against.\r\n\r\n```php\r\n$intersect = $periodCollection-\u003eintersect($period);\r\n```\r\n\r\nThis method will return a new *PeriodCollection*.\r\n\r\n**Overlap All**\r\n\r\nGet the overlap of all the collections.\r\n\r\nAll arguments supplied will be used as collections to compare against.\r\n\r\n```php\r\n$overlapAll = $periodCollection-\u003eoverlapAll(...$others);\r\n```\r\n\r\nThis method will return a new *PeriodCollection*.\r\n\r\n**Sort**\r\n\r\nSort the periods.\r\n\r\n```php\r\n$sorted = $periodCollection-\u003esort();\r\n```\r\n\r\nThis method will return a new *PeriodCollection*.\r\n\r\n**Subtract**\r\n\r\nGet the inverse overlap of the collections.\r\n\r\n- `$others` is the *PeriodCollection* to compare against.\r\n\r\n```php\r\n$subtract = $periodCollection-\u003esubtract($others);\r\n```\r\n\r\nThis method will return a new *PeriodCollection*.\r\n\r\n**Unique**\r\n\r\nFilter the periods to remove duplicates.\r\n\r\n```php\r\n$unique = $periodCollection-\u003eunique();\r\n```\r\n\r\nThis method will return a new *PeriodCollection*.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreperiod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felusivecodes%2Ffyreperiod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felusivecodes%2Ffyreperiod/lists"}