{"id":37013911,"url":"https://github.com/railt/carbon-extension","last_synced_at":"2026-01-14T01:23:08.354Z","repository":{"id":62532868,"uuid":"130360795","full_name":"railt/carbon-extension","owner":"railt","description":"An extension that provides objects for working with a date and time using the Carbon library","archived":true,"fork":false,"pushed_at":"2019-01-15T16:20:03.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-12T05:22:31.335Z","etag":null,"topics":["carbon","datetime-format","extension","railt"],"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/railt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-20T12:43:56.000Z","updated_at":"2023-01-28T18:45:22.000Z","dependencies_parsed_at":"2022-11-02T15:02:22.002Z","dependency_job_id":null,"html_url":"https://github.com/railt/carbon-extension","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/railt/carbon-extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railt%2Fcarbon-extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railt%2Fcarbon-extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railt%2Fcarbon-extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railt%2Fcarbon-extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/railt","download_url":"https://codeload.github.com/railt/carbon-extension/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/railt%2Fcarbon-extension/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28407691,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T00:40:43.272Z","status":"ssl_error","status_checked_at":"2026-01-14T00:40:42.636Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["carbon","datetime-format","extension","railt"],"created_at":"2026-01-14T01:23:06.187Z","updated_at":"2026-01-14T01:23:08.325Z","avatar_url":"https://github.com/railt.png","language":"PHP","readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://railt.org/images/logo-dark.svg\" width=\"200\" alt=\"Railt\" /\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://travis-ci.org/railt/carbon-extension\"\u003e\u003cimg src=\"https://travis-ci.org/railt/carbon-extension.svg?branch=master\" alt=\"Travis CI\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://styleci.io/repos/130360795?branch=master\"\u003e\u003cimg src=\"https://styleci.io/repos/130360795/shield?b=master\" alt=\"StyleCI\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/railt/carbon-extension/?branch=master\"\u003e\u003cimg src=\"https://scrutinizer-ci.com/g/railt/carbon-extension/badges/coverage.png?b=master\" alt=\"Code coverage\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://scrutinizer-ci.com/g/railt/carbon-extension/?branch=master\"\u003e\u003cimg src=\"https://scrutinizer-ci.com/g/railt/carbon-extension/badges/quality-score.png?b=master\" alt=\"Scrutinizer CI\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/railt/carbon-extension\"\u003e\u003cimg src=\"https://poser.pugx.org/railt/carbon-extension/version\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/railt/carbon-extension\"\u003e\u003cimg src=\"https://poser.pugx.org/railt/carbon-extension/v/unstable\" alt=\"Latest Unstable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://raw.githubusercontent.com/railt/carbon-extension/master/LICENSE\"\u003e\u003cimg src=\"https://poser.pugx.org/railt/carbon-extension/license\" alt=\"License MIT\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Carbon Extension\n\n**Table of contents**\n- [Installation](#installation)\n    - [Laravel](#laravel)\n    - [Symfony](#symfony)\n- [Output](#output)\n    - [Formats](#output-formats)\n- [Input](#input)\n    - [Formats](#input-formats)\n\n## Installation\n\n- `composer require railt/carbon-extension`\n- Add extension to your application:\n\n```php\n$app = new Railt\\Foundation\\Application();\n\n$app-\u003eextend(Railt\\CarbonExtension\\Extension::class); // Here\n```\n\n### Laravel\n\nIn that case, if you use [Laravel Service Provider](https://github.com/railt/laravel-provider) \nthis extension can be added as follows:\n\nOpen the `railt.php` configuration file and add:\n\n```php\n'extensions' =\u003e [\n    // ...\n    \\Railt\\CarbonExtension\\Extension::class, // Here\n]\n```\n\n### Symfony\n\nIn that case, if you use [Symfony Bundle](https://github.com/railt/symfony-bundle) \nthis extension can be added as follows:\n\nOpen the `config.yml` configuration file and add:\n\n```yml\nrailt:\n    extensions:\n        - Railt\\CarbonExtension\\Extension # Here\n```\n\n## Output\n\nYou can use it within your types. After you add type `Carbon`, \ntwo optional arguments appear in the field which is defined by this type.\n\nThose. Client will see the following scheme:\n\n```graphql\n# Definition\ntype YourExampleType {\n    id: ID!\n    some: String!\n    createdAt: Carbon!\n}\n\n# What the client will see\ntype YourExampleType {\n    id: ID!\n    some: String!\n    createdAt(\n        \"\"\"\n        An argument that provides a format of the given value that \n        are contained in a CarbonFormat enumeration type.\n        \"\"\"\n        format: CarbonFormat = RFC3339\n    ): Carbon!\n}\n```\n\nIn order to correctly return data - just pass the date type.\n\n\u003e Note: The \"createdAt\" field should provide datetime compatible type, like:\n\u003e 1) DateTime object: http://php.net/manual/en/class.datetime.php\n\u003e 2) Carbon object: https://carbon.nesbot.com/docs/\n\u003e 3) String datetime format\n\u003e 4) Integer timestamp\n\n```php\npublic function resolver(): array\n{\n    return [\n        'id'        =\u003e 42,\n        'some'      =\u003e 'Example',\n        'createdAt' =\u003e '2018-04-28T17:55:27+00:00', // Yesterday\n    ];\n}\n```\n\nThe request might look like this:\n\n```graphql\n{\n    example {\n        id\n        some\n        a: createdAt(format: COOKIE)\n        b: createdAt(format: HUMAN_READABLE)\n    }\n}\n```\n\nThe response is as follows:\n\n```json\n{\n    \"example\": {\n        \"id\": 42,\n        \"some\": \"Example\",\n        \"createdAt\": \"Saturday, 28-Apr-2018 17:55:27 GMT+0000\",\n        \"a\": \"Saturday, 28-Apr-2018 17:55:27 GMT+0000\",\n        \"b\": \"4 months ago\"\n    }\n}\n```\n\n### Output formats\n\nThe return value can correspond to one of the valid formats defined in the \n`CarbonFormat` enumeration. In order to specify what date format in the \nresponse you want to see - it should be passed as the value of the `format` argument.\n\n```graphql\n{\n    example {\n        createdAt(format: COOKIE) \n        # createdAt field date will return in the COOKIE format.\n    }\n}\n```\n\nBelow is a list of valid `CarbonFormat` enum formats:\n\n- **ISO8601** - ISO-8601 date format.\n\u003e Example: `2005-08-15T15:52:01+00:00`\n\u003e Note: This format is an alias of the RFC 3339 specification:\n\u003e ISO8601: https://www.iso.org/iso-8601-date-and-time-format.html\n\u003e RFC3339: https://www.ietf.org/rfc/rfc3339.txt\n\n- **RFC822** - RFC 822 date format.\n\u003e Example: `Mon, 15 Aug 05 15:52:01 +0000`\n\n- **RFC850** - RFC 850 date format.\n\u003e Example: `Monday, 15-Aug-05 15:52:01 UTC`\n\n- **RFC1036** - RFC 1036 date format.\n\u003e Example: `Mon, 15 Aug 05 15:52:01 +0000`\n\n- **RFC1123** - RFC 1123 date format.\n\u003e Example: `Mon, 15 Aug 2005 15:52:01 +0000`\n\n- **RFC2822** - RFC 2822 date format.\n\u003e Example: `Mon, 15 Aug 2005 15:52:01 +0000`\n\n- **RFC3339** - RFC 3339 date format.\n\u003e Example: `2005-08-15T15:52:01+00:00`\n\u003e Note: This format is an alias of the ISO-8601 specification:\n\u003e RFC3339: https://www.ietf.org/rfc/rfc3339.txt\n\u003e ISO8601: https://www.iso.org/iso-8601-date-and-time-format.html\n\n- **RFC3339_EXTENDED** - RFC 3339 date format. In contrast to the usual RFC3339 additionally contains milliseconds.\n\u003e Example: `2005-08-15T15:52:01.000+00:00`\n\n- **RFC7231** - RFC 7231 date format.\n\u003e Example: `Mon, 15 Aug 2005 15:52:01 GMT`\n\n- **COOKIE** - HTTP Cookies date format.\n\u003e Example: `Monday, 15-Aug-2005 15:52:01 UTC`\n\n- **DATE_TIME** - Simple DateTime format.\n\u003e Example: `2005-08-15 15:52:01`\n\n- **DATE** - Simple Date format.\n\u003e Example: `2005-08-15`\n\n- **TIME** - Simple Time format.\n\u003e Example: `15:52:01`\n\n- **RSS** - RSS date format.\n\u003e Example: `Mon, 15 Aug 2005 15:52:01 +0000`\n\n- **W3C** - World Wide Web Consortium date format.\n\u003e Example: `2005-08-15T15:52:01+00:00`\n\n- **HUMAN_READABLE** - Human readable string.\n\u003e Example: `2 days ago`\n\n## Input\n\nA scalar `Carbon` type can be passed as an argument to any field.\nIn this case it will be coerced into `Carbon` PHP object.\n\n```graphql\n# Definition\ntype Example {\n    field(arg: Carbon!): String\n}\n```\n\n```php\n// Resolver\n// Note: \"$arg\" argument definition similar with \"$input-\u003eget('arg')\"\npublic function handle(\\DateTimeInterface $arg)\n{\n    return $arg-\u003eformat(\\DateTime::RFC3339);\n}\n```\n\n```graphql\n# Query\n{\n    field(arg: \"now\")\n}\n```\n\n```json\n{\n    \"field\": \"2018-04-29T17:55:27+00:00\"\n}\n```\n\n### Input formats\n\nAs the admissible input values, the [following formats](http://php.net/manual/en/datetime.formats.php) are allowed:\n\n- [Time Formats](http://php.net/manual/en/datetime.formats.time.php)\n- [Date Formats](http://php.net/manual/en/datetime.formats.date.php)\n- [Compound Formats](http://php.net/manual/en/datetime.formats.compound.php)\n- [Relative Formats](http://php.net/manual/en/datetime.formats.relative.php)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frailt%2Fcarbon-extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frailt%2Fcarbon-extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frailt%2Fcarbon-extension/lists"}