{"id":3000,"url":"https://github.com/SwiftKitz/Datez","last_synced_at":"2025-08-06T13:32:26.242Z","repository":{"id":56908281,"uuid":"45747499","full_name":"SwiftKitz/Datez","owner":"SwiftKitz","description":"📆 Breeze through Date, DateComponents, and TimeInterval with Swift!","archived":false,"fork":false,"pushed_at":"2020-12-04T08:18:18.000Z","size":13414,"stargazers_count":261,"open_issues_count":0,"forks_count":12,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-07-03T19:45:27.716Z","etag":null,"topics":["calendar","carthage","cocoapods","date","datetime","ios","macos","swift","timeinterval","tvos","watchos"],"latest_commit_sha":null,"homepage":"https://swiftkitz.github.io/","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/SwiftKitz.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}},"created_at":"2015-11-07T17:52:39.000Z","updated_at":"2023-07-17T07:09:02.000Z","dependencies_parsed_at":"2022-08-20T19:50:25.801Z","dependency_job_id":null,"html_url":"https://github.com/SwiftKitz/Datez","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FDatez","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FDatez/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FDatez/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SwiftKitz%2FDatez/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SwiftKitz","download_url":"https://codeload.github.com/SwiftKitz/Datez/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":214012065,"owners_count":15670479,"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":["calendar","carthage","cocoapods","date","datetime","ios","macos","swift","timeinterval","tvos","watchos"],"created_at":"2024-01-05T20:16:28.605Z","updated_at":"2024-08-17T16:30:45.226Z","avatar_url":"https://github.com/SwiftKitz.png","language":"Swift","readme":"\n\u003ch1 align=\"center\"\u003e\n  Datez :calendar:\n\u003ch6 align=\"center\"\u003e\n  Breeze through Date, DateComponents, and TimeInterval\n\u003c/h6\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003cimg alt=\"Version\" src=\"https://img.shields.io/badge/version-4.1.0-blue.svg\" /\u003e\n  \u003ca alt=\"Github CI\" href=\"https://github.com/SwiftKitz/Datez/actions\"\u003e\n    \u003cimg alt=\"Version\" src=\"https://github.com/SwiftKitz/Datez/workflows/Swift/badge.svg\" /\u003e\n  \u003c/a\u003e\n  \u003cimg alt=\"Swift\" src=\"https://img.shields.io/badge/swift-5.3-orange.svg\" /\u003e\n  \u003cimg alt=\"Platforms\" src=\"https://img.shields.io/badge/platform-ios%20%7C%20osx%20%7C%20watchos%20%7C%20tvos-lightgrey.svg\" /\u003e\n  \u003cimg src=\"resources/Demo.gif\"\u003e\n\u003c/p\u003e\n\n## Highlights\n\n+ __Two Custom Structs Only _(value types FTW!)_:__\n  - __`DateView`__: An `Date` associated with an `Calendar`\n  - __`CalendarComponents`__: Like `DateComponents`, but `Calendar` agnostic.\n\n+ __Absolutely _Zero_ Hardcode:__\u003cbr /\u003e\nOnly hardcode now is to clear the date components, by setting the value to `0` or `1`. Nothing like:\u003cbr /\u003e\n`minutes = seconds * 60`.\n\n+ __Modular Composition Design:__\u003cbr /\u003e\nOnly one way to achieve something, instead of copy pasting code everywhere, with tons of head scratching.\n\n## Features\n\nYou can try them in the playground shipped with the framework!\n\n__Quickly and Explicitly Access Date Components:__\n\n```swift\nlet someDate = Date()\nlet currentCalendar = someDate.currentCalendar.components.year\nlet gregorianDay = someDate.gregorian.components.day\nlet hijriMonth = someDate.islamicCivil.components.month\n```\n\n__Easy and Concise Date Manipulation:__\n\n```swift\nlet date = Date()\nlet gregorianDate = date.gregorian\n\n// Adding components\nlet tomorrow = gregorianDate + 1.day\n\n// Relative accessors\nlet firstThingTomorrow = tomorrow.beginningOfDay\n\n// Easy tweaking\nlet firstThingTomorrowButIn1984 = firstThingTomorrow.update(year: 1984)\n\n// now, lets get the date\nlet newDate = firstThingTomorrowButIn1984.date\n```\n\n__Convenient Date Operators:__\n\n```swift\n// Just calling timeIntervalSinceDate\nlet difference = Date(timeIntervalSinceNow: 5.minutes.timeInterval) - Date()\n\n// Just calling dateByAddingTimeInterval\nlet afterFiftyHours = Date() + 50.hours.timeInterval\n\n// Just calling compare:\nlet compareResult = Date(timeIntervalSinceNow: 8.hours.timeInterval) \u003c Date()\n```\n\n__[Bonus]: Durations__\u003cbr /\u003e\nThis is marked as bonus since it's not ideal at all for precise calculation, but super useful when you just need some convenience. Examples would be setting expiration intervals and estimating components from `TimeInterval`\n\n```swift\n// Easily access TimeInterval to construct durations\nlet expirationInterval = 300.days.timeInterval\n\n// Convert back to a single date component\nlet months = expirationInterval.totalMonths // 9\n\n// Or multiple components\nlet components = expirationInterval.components\n// components ≈ CalendarComponents(day: 6, month: 9)\n```\n\n## Getting Started\n\n### Swift Package Manager\n\n```\nTODO: Write me\n```\n\n### CocoaPods\n\n[CocoaPods][cocoapods-link] is fully supported. Simply add the following line to your [Podfile][podfile-docs]:\n\n```ruby\npod 'Datez'\n```\n\n### Submodule\n\nFor manual installation, you can grab the source directly or through git submodules, then simply:\n\n+ Drop the `Datez.xcodeproj` file as a subproject (make sure `Copy resources` is __not__ enabled)\n+ Navigate to your root project settings. Under \"Embedded Binaries\", click the \"+\" button and select the `Datez.framework`\n\n## Motivation\n\nThis framework doesn't reinvent anything Apple already built. Under the hood, it leverages the `Date`, `Calendar`, and `DateComponents` classes to do all the work. It simply tries to simplify the API for Swift developers. Period.\n\nAfter experiencing what using a great Swift API feels like, by using RealmSwift and SwiftyJSON, I started to believe in the importance of a clean and concise Swift API, and its impact on our productivity and stress levels.\n\n_What's wrong with other date libraries?_\n\n__Assuming the underlying `Calendar`__:\u003cbr /\u003e\nI needed to explicitly choose between Gregorian and IslamicCivil, so that is integrated.\n\n__Wrong Date Calculation__:\u003cbr /\u003e\nMost frameworks I've seen make assumptions about the number of days in a month, or hardcode the number of hours ... etc.\n\n## Author\n\nMazyod ([@Mazyod](http://twitter.com/mazyod))\n\n## License\n\nDatez is released under the MIT license. See LICENSE for details.\n\n\n[carthage-link]: https://github.com/Carthage/Carthage\n[cartfile-docs]: https://github.com/Carthage/Carthage/blob/master/Documentation/Artifacts.md#cartfile\n[cocoapods-link]: https://cocoapods.org/\n[podfile-docs]: https://guides.cocoapods.org/syntax/podfile.html\n","funding_links":[],"categories":["Utility","Libs","Date [🔝](#readme)"],"sub_categories":["Web View","Date","Other free courses"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftKitz%2FDatez","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSwiftKitz%2FDatez","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSwiftKitz%2FDatez/lists"}