{"id":33991545,"url":"https://github.com/veloxy/opening-hours","last_synced_at":"2025-12-13T06:51:32.209Z","repository":{"id":57056065,"uuid":"70743137","full_name":"veloxy/opening-hours","owner":"veloxy","description":"This is a small library that helps you do several checks on opening hours.","archived":false,"fork":false,"pushed_at":"2018-07-17T22:04:54.000Z","size":84,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-11-27T16:32:18.684Z","etag":null,"topics":["library","opening-hours","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/veloxy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-12T21:28:10.000Z","updated_at":"2020-11-15T04:34:13.000Z","dependencies_parsed_at":"2022-08-24T07:21:09.732Z","dependency_job_id":null,"html_url":"https://github.com/veloxy/opening-hours","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/veloxy/opening-hours","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veloxy%2Fopening-hours","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veloxy%2Fopening-hours/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veloxy%2Fopening-hours/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veloxy%2Fopening-hours/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/veloxy","download_url":"https://codeload.github.com/veloxy/opening-hours/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/veloxy%2Fopening-hours/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27701841,"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","status":"online","status_checked_at":"2025-12-13T02:00:09.769Z","response_time":147,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["library","opening-hours","php"],"created_at":"2025-12-13T06:51:31.484Z","updated_at":"2025-12-13T06:51:32.195Z","avatar_url":"https://github.com/veloxy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Opening Hours\n\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![SensioLabs Insight][ico-sensio]][link-sensio]\n[![StyleCI][ico-styleci]][link-styleci]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n\nThis is a small library that helps you do several checks on opening hours.\n\n## Requirements\n\n- PHP 7.0+\n\n## Installation\n\nYou can install this library using composer, note that it's still in development and may or may not change drastically before the first version is released.\n\n```\ncomposer require sourcebox/opening-hours\n```\n\n## Quick Usage\n \nYou can easily figure out the usage by checking out the tests, but here's a quick example:\n\n### Create a TimeTable\n\nA TimeTable contains your opening hours, it consists of an array of days that each have a set of TimePeriods.\nA day that doesn't have time periods or a day that doesn't exist in the time table is considered a closed day. \n\n```php\n$timeTable = new TimeTable([\n   new Day(Day::MONDAY, [\n       new TimePeriod('08:00', '12:00'),\n       new TimePeriod('13:00', '17:00'),\n   ]),\n   new Day(Day::TUESDAY, [\n       new TimePeriod('08:00', '12:00'),\n       new TimePeriod('13:00', '17:00'),\n   ]),\n   new Day(Day::WEDNESDAY, [\n       new TimePeriod('08:00', '12:00'),\n       new TimePeriod('13:00', '17:00'),\n   ]),\n   new Day(Day::THURSDAY, [\n       new TimePeriod('08:00', '12:00'),\n       new TimePeriod('13:00', '17:00'),\n   ]),\n   new Day(Day::FRIDAY, [\n       new TimePeriod('08:00', '12:00'),\n       new TimePeriod('13:00', '17:00'),\n   ]),\n   new Day(Day::SATURDAY, [\n       new TimePeriod('08:00', '12:00'),\n   ]),\n]);\n\n$checker = new OpeningHourChecker($timeTable);\n```\n\nThe timetable is passed to the opening hour checker so we can start checking stuff.\n\n### Basic checks\n\nThe OpeningHourChecker consists of a few basic checks.\n\n#### Check if it's open on a certain day.\n\nThis is a very simple check, only checks if there are time periods for the given day.\n\n```php\n$checker-\u003eisOpenOn(Day::TUESDAY); // true\n$checker-\u003eisClosedOn(Day::TUESDAY); // false\n```\n\n#### Check if it's open on a certain date and time\n\nThis check will check the time periods for a given day and time.\n\n```php\n$checker-\u003eisOpenAt(\\DateTime::createFromFormat('Y-m-d H:i:s', '2016-10-10 10:00:00'))); // returns true\n$checker-\u003eisClosedAt(\\DateTime::createFromFormat('Y-m-d H:i:s', '2016-10-10 10:00:00'))); // returns false\n```\n\n#### Overrides\n\nOverrides are basically exceptions to the timetable. There's two types of overrides, includes and excludes.\nInclude overrides are dates that are included, exclude overrides are dates that are excluded.\n\nThere are currently two override classes included.\n\n##### Example\n\nThis example adds christmas date as an exclusion override, which means that christmas day is excluded from the timetable. \nThis is handy when you want your store to be closed on certain dates.\n\n```php\n$dateOverride = new DateOverride($christmasDateTime);\n$dateOverride-\u003esetType(OverrideInterface::TYPE_EXCLUDE);\n\n$openingHourChecker-\u003eaddOverride($dateOverride);\n$openingHourChecker-\u003eisOpenAt($christmasDateTime); // return false\n```\n\nThe reverse is also possible, say you want to open all day on black friday, regardless of opening hours. \nYou'd use the same `DateOverride` but set the type to `TYPE_INCLUDE`. Not that the overrides prioritize excludes over includes.\n\nThere's also a DatePeriodOverride, which does the same as the DateOverride but for a period.\n\n```php\n$holidayPeriodStart = \\DateTime::createFromFormat('Y-m-d H:i:s', '2017-01-01 00:00:00', $timezone);\n$holidayPeriodEnd = \\DateTime::createFromFormat('Y-m-d H:i:s', '2017-01-10 00:00:00', $timezone);\n$holidayPeriod = new DatePeriodOverride($holidayPeriodStart, $holidayPeriodEnd);\n$holidayPeriod-\u003esetType(OverrideInterface::TYPE_EXCLUDE);\n\n$openingHourChecker-\u003eaddOverride($holidayPeriod);\n```\n\nIn this example, store is closed from `$holidayPeriodStart` until `$holidayPeriodEnd`. \n\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/veloxy/opening-hours/master.svg?style=flat-square\n[ico-sensio]: https://img.shields.io/sensiolabs/i/7d757865-5835-414c-9591-06ce50bb15a7.svg?maxAge=3600\u0026style=flat-square\n[ico-styleci]: https://styleci.io/repos/70743137/shield?branch=master\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/veloxy/opening-hours.svg?style=flat-square\n\n[link-scrutinizer]: https://scrutinizer-ci.com/g/veloxy/opening-hours/code-structure\n[link-travis]: https://travis-ci.org/veloxy/opening-hours\n[link-sensio]: https://insight.sensiolabs.com/projects/7d757865-5835-414c-9591-06ce50bb15a7\n[link-styleci]: https://styleci.io/repos/70743137\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveloxy%2Fopening-hours","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fveloxy%2Fopening-hours","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fveloxy%2Fopening-hours/lists"}