{"id":20235333,"url":"https://github.com/phphleb/calendar-stub","last_synced_at":"2026-02-02T04:02:13.172Z","repository":{"id":57747645,"uuid":"523244798","full_name":"phphleb/calendar-stub","owner":"phphleb","description":"Solving the problem with calendar calculations in PHP","archived":false,"fork":false,"pushed_at":"2024-12-06T00:32:54.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-25T23:10:07.002Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/phphleb.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}},"created_at":"2022-08-10T07:29:48.000Z","updated_at":"2024-11-24T22:04:30.000Z","dependencies_parsed_at":"2022-09-05T23:50:06.604Z","dependency_job_id":null,"html_url":"https://github.com/phphleb/calendar-stub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phphleb%2Fcalendar-stub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phphleb%2Fcalendar-stub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phphleb%2Fcalendar-stub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phphleb%2Fcalendar-stub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phphleb","download_url":"https://codeload.github.com/phphleb/calendar-stub/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233828157,"owners_count":18736578,"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":[],"created_at":"2024-11-14T08:15:55.635Z","updated_at":"2025-09-22T05:32:31.300Z","avatar_url":"https://github.com/phphleb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# php Calendar Stub\n\n### Генерация объекта даты начала или окончания периода, заданного по названию.\n\nРешает проблему точных календарных дат в DateTime, при которой, например,\nзначение `(new DateTime('2017-01-31'))-\u003emodify('+1 month')-\u003eformat('Y-m-d')` равно \"2017-03-03\"\nа не \"2017-02-28\".\n\n\n#### Установка\n```bash\n$ composer require phphleb/calendar-stub\n```\n#### Использование\n\n```php\nuse Phphleb\\CalendarStub\\DateNameToPeriodConverter;\n$converter = new DateNameToPeriodConverter();\n\n// Получение даты за календарный месяц назад от текущего времени.\n// Возможные значения периода: 'day', 'week', 'month', 'quarter', 'year', 'all'\n// Период может быть кратным, например '2 months'.\n// Методы getStartDate и getEndDate возвращают объект DateTime.\n$date = $converter\n        -\u003esetPeriodName('month')\n        -\u003egetStartDate()\n        -\u003eformat('Y-m-d H:i:s');\n\n// Получение даты два календарных месяца назад от текущего времени.\n$date = $converter\n        -\u003esetPeriodName('2 months')\n        -\u003egetStartDate()\n        -\u003eformat('Y-m-d H:i:s');\n        \n// Получение даты два календарных месяца вперед от текущего времени.\n$date = $converter\n        -\u003esetPeriodName('2 months')\n        -\u003esetStartDate(new DateTime())\n        -\u003egetEndDate()\n        -\u003eformat('Y-m-d H:i:s');\n\n// Получение даты два календарных месяца назад от заданного времени (28го февраля 2017).\n$endPeriod = new DateTime('2017-02-28 00:00::00');\n$date = $converter\n        -\u003esetPeriodName('2 months')\n        -\u003esetEndDate($endPeriod)\n        -\u003egetStartDate()\n        -\u003eformat('Y-m-d H:i:s');\n\n// При задании периода \"all\" ничего не рассчитывается, так как возвращается или\n// start date от начала UNIX Time, так и уже установленная end date или текущее время.\n$date = $converter\n        -\u003esetPeriodName('all')\n        -\u003egetEndDate()\n        -\u003eformat('Y-m-d H:i:s');\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphphleb%2Fcalendar-stub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphphleb%2Fcalendar-stub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphphleb%2Fcalendar-stub/lists"}