{"id":30106817,"url":"https://github.com/createapi/naivedate","last_synced_at":"2026-03-03T22:31:26.604Z","repository":{"id":44362892,"uuid":"112485682","full_name":"CreateAPI/NaiveDate","owner":"CreateAPI","description":"Naive date and time","archived":false,"fork":false,"pushed_at":"2024-09-13T00:13:04.000Z","size":72,"stargazers_count":50,"open_issues_count":4,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-10T01:14:50.548Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","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/CreateAPI.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2017-11-29T14:30:17.000Z","updated_at":"2025-04-21T15:07:18.000Z","dependencies_parsed_at":"2024-09-13T10:48:43.200Z","dependency_job_id":null,"html_url":"https://github.com/CreateAPI/NaiveDate","commit_stats":{"total_commits":42,"total_committers":2,"mean_commits":21.0,"dds":0.04761904761904767,"last_synced_commit":"97176a265165680313f4c3a34e98ab1303932912"},"previous_names":["kean/naivedate"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/CreateAPI/NaiveDate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateAPI%2FNaiveDate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateAPI%2FNaiveDate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateAPI%2FNaiveDate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateAPI%2FNaiveDate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CreateAPI","download_url":"https://codeload.github.com/CreateAPI/NaiveDate/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CreateAPI%2FNaiveDate/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272611889,"owners_count":24964385,"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-08-29T02:00:10.610Z","response_time":87,"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":[],"created_at":"2025-08-10T01:10:40.076Z","updated_at":"2025-12-11T23:01:39.922Z","avatar_url":"https://github.com/CreateAPI.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NaiveDate\n\n\u003cp align=\"left\"\u003e\n\u003cimg src=\"https://img.shields.io/cocoapods/p/NaiveDate.svg?style=flat)\"\u003e\n\u003c/p\u003e\n\nThe standard `Date` type is excellent for working with timestamps and time zones (e.g. `2024-09-29T15:00:00+0300`), but there are scenarios where you don't know or care about the time zone. These types of dates are often referred to as **naive**.\n\n\n## Usage\n\nThe `NaiveDate` library implements three types:\n\n- `NaiveDate` (e.g. `2024-09-29`)\n- `NaiveTime` (e.g. `15:30:00`)\n- `NaiveDateTime` (e.g. `2024-09-29T15:30:00` - no time zone and no offset).\n\nThey all implement `Equatable`, `Comparable`, `LosslessStringConvertible`, and `Codable` protocols. Naive date types can also be converted to `Date`, and `DateComponents`.\n\n### Create\n\nNaive dates and times can be created from a string (using a predefined format – [RFC 3339](https://datatracker.ietf.org/doc/html/rfc3339#section-5.6), using `Decodable`, or with a memberwise initializer:\n\n```swift\nNaiveDate(\"2024-10-01\")\nNaiveDate(year: 2024, month: 10, day: 1)\n\nNaiveTime(\"15:30:00\")\nNaiveTime(hour: 15, minute: 30, second: 0)\n\nNaiveDateTime(\"2024-10-01T15:30\")\nNaiveDateTime(\n    date: NaiveDate(year: 2024, month: 10, day: 1),\n    time: NaiveTime(hour: 15, minute: 30, second: 0)\n)\n```\n\n### Format\n\n`NaiveDate` supports `Foundation.FormatStyle`:\n\n```swift\nlet dateTime = NaiveDateTime(\"2024-11-01T15:30:00\")!\ndateTime.formatted(date: .numeric, time: .standard)\n// prints \"11/1/2024, 3:30:00 PM\"\n```\n\nIn addition to the format style, you can use built-in `NaiveDateFormatter` directly.\n\n```swift\nlet date = NaiveDate(\"2024-11-01\")!\nNaiveDateFormatter(dateStyle: .short).string(from: date)\n// prints \"Nov 1, 2024\"\n\nlet time = NaiveTime(\"15:00\")!\nNaiveDateFormatter(timeStyle: .short).string(from: time)\n// prints \"3:00 PM\"\n\nlet dateTime = NaiveDateTime(\"2024-11-01T15:30:00\")!\nNaiveDateFormatter(dateStyle: .short, timeStyle: .short).string(from: dateTime)\n// prints \"Nov 1, 2024 at 3:30 PM\"\n```\n\n### Convert\n\nWhen you do need to work with time zones, simply convert `NaiveDate` to `Date`:\n\n```swift\nlet date = NaiveDate(year: 2024, month: 10, day: 1)\n\n// Creates `Date` in a calendar's time zone\n// \"2024-10-01T00:00:00+0300\" if user is in MSK\nCalendar.current.date(from: date)\n```\n\n```swift\nlet dateTime = NaiveDateTime(\n    date: NaiveDate(year: 2024, month: 10, day: 1),\n    time: NaiveTime(hour: 15, minute: 30, second: 0)\n)\n\n// Creates `Date` in a calendar's time zone\n// \"2024-10-01T15:30:00+0300\" if user is in MSK\nCalendar.current.date(from: dateTime)\n```\n\n**Important!** The naive types are called this way because they don’t have a time zone associated with them. This means the date may not actually exist in some areas in the world, even though they are “valid”. For example, when daylight saving changes are applied the clock typically moves forward or backward by one hour. This means certain dates never occur or may occur more than once. If you need to do any precise manipulations with time, always use native `Date` and `Calendar`.\n\n## Minimum Requirements\n\n| NaiveDate            | Swift            | Platforms                                  |\n|----------------------|------------------|--------------------------------------------|\n| NaiveDate 1.1        | Swift 5.9        | iOS 13, tvOS 13, watchOS 6, macOS 10.15    |\n| NaiveDate 1.0        | Swift 5.3        | iOS 11, tvOS 11, watchOS 4, macOS 10.13,   |\n\n## License\n\nNaiveDate is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreateapi%2Fnaivedate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcreateapi%2Fnaivedate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcreateapi%2Fnaivedate/lists"}