{"id":26584042,"url":"https://github.com/kawoou/anydate","last_synced_at":"2025-06-15T13:05:22.427Z","repository":{"id":56902074,"uuid":"97414965","full_name":"kawoou/AnyDate","owner":"kawoou","description":"Swifty Date \u0026 Time API inspired from Java 8 DateTime API.","archived":false,"fork":false,"pushed_at":"2025-06-12T15:59:25.000Z","size":553,"stargazers_count":191,"open_issues_count":4,"forks_count":13,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-12T16:50:17.150Z","etag":null,"topics":["datetime","ios","java","linux","macos","swift","timezone","tvos","watchos"],"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/kawoou.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":"2017-07-16T22:26:55.000Z","updated_at":"2025-02-22T00:00:12.000Z","dependencies_parsed_at":"2022-08-21T01:50:47.184Z","dependency_job_id":null,"html_url":"https://github.com/kawoou/AnyDate","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/kawoou/AnyDate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawoou%2FAnyDate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawoou%2FAnyDate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawoou%2FAnyDate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawoou%2FAnyDate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kawoou","download_url":"https://codeload.github.com/kawoou/AnyDate/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kawoou%2FAnyDate/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259981458,"owners_count":22941147,"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":["datetime","ios","java","linux","macos","swift","timezone","tvos","watchos"],"created_at":"2025-03-23T09:17:49.705Z","updated_at":"2025-06-15T13:05:22.365Z","avatar_url":"https://github.com/kawoou.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AnyDate\n\n[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)\n![Swift](https://img.shields.io/badge/Swift-5.0-orange.svg)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Version](https://img.shields.io/cocoapods/v/AnyDate.svg?style=flat)](http://cocoadocs.org/docsets/AnyDate)\n[![License](https://img.shields.io/cocoapods/l/AnyDate.svg?style=flat)](https://github.com/kawoou/AnyDate/blob/master/LICENSE)\n[![CI Status](https://travis-ci.org/kawoou/AnyDate.svg?branch=master)](https://travis-ci.org/kawoou/AnyDate)\n[![Codecov](https://img.shields.io/codecov/c/github/kawoou/AnyDate.svg)](https://codecov.io/gh/kawoou/AnyDate)\n[![Platform](https://img.shields.io/cocoapods/p/AnyDate.svg?style=flat)](http://cocoadocs.org/docsets/AnyDate)\n[![Jazzy](http://kawoou.kr/AnyDate/badge.svg)](http://kawoou.kr/AnyDate)\n\nSwifty Date \u0026 Time API inspired from Java 8 DateTime API.\n\n\n## Background\n\nI think that date \u0026 time API should be easy and accurate.\n\nPrevious dates, times, timezones API of Swift are inconvenience to use. (It's very complex to create, manipulate or everything else.)\n\nBut there's quite nice pioneer, ***The Brand New Time API of Java8***.\n\nJava 8 introduced whole new API for handle date \u0026 time more efficiently and easy a.k.a LocalDateTime, ZonedDateTime(JSR-310). The main idea that is:\n\n* Immutable-value classes\n* Domain-driven design\n* Separation of chronologies\n\nThose ideas can be easily ported to another languages, like .Net's Rx ports of another languages.\n\n\n\nSo, here's the AnyDate, whole new Swift date \u0026 time API that has coherence between Java 8.\n\n\n\n\n## Features\n\n* [x] Convinience typed year, month, day, time.\n* [x] Pre-defined Timezone Identifiers.\n* [x] Null-Safe types.\n* [x] Separation of chronologies.\n* [x] Coherence with Java.\n* [x] Operators supported.\n* [x] Easy to manipulate.\n\n\n\n\n## FAQ\n\n* Looks like SwiftDate?\n  - SwiftDate is a support library for Date, AnyDate can completely replace Date.\n\n\n\n\n## Usage\n\n* Convinience typed year, month, day, time.\n\n```swift\n/// Before\nlet now1 = Date()\nvar calendar = Calendar.current\ncalendar.timeZone = TimeZone(identifier: \"UTC\")!\n\nlet day = calendar.components(.day, from: now1)\n\n/// After\nlet now2 = ZonedDateTime(Clock.utc)\nlet day = now2.day\n```\n\n* Pre-defined Timezone Identifiers. String typed timezones are not safe from your *TYPING ERROR*. (Plz, do not belive your finger. They can always betray you.)\n\n```swift\n/// Before\nlet timeZone1 = TimeZone(identifier: \"GMT+0900\")!\nlet timeZone2 = TimeZone(identifier: \"America/Argentina/Buenos_Aires\")!\n\n/// After\nlet clock1 = Clock(offsetHour: 9)\nlet clock2 = Clock(identifier: .americaArgentinaBuenosAires)\n```\n\n* Null-Safe types. ***NO MORE NEEDLESS GUARD \u0026 OPTIONAL AND INDENT INCRESEMENT :-D***\n\n```swift\n/// Before\nvar dateComponents = DateComponents()\ndateComponents.year = 2000\ndateComponents.month = 11\ndateComponents.day = 30\ndateComponents.hour = 11\ndateComponents.minute = 51\ndateComponents.second = 18\ndateComponents.nanosecond = 1573\n\nguard let date = Calendar.current.date(from: dateComponents) else {\n    assertionFailure(\"Failed to create!\")\n    return\n}\n\n/// After\nlet date = LocalDateTime(\n    year: 2000,\n    month: 11,\n    day: 30,\n    hour: 11,\n    minute: 51,\n    second: 18,\n    nanoOfSecond: 1573\n)\n```\n\n* Operators supported. Easy to compare dates, datetimes, times.\n\n```swift\nlet min = ZonedDateTime.min\nlet max = ZonedDateTime.max\n\nlet oldDate = ZonedDateTime(year: 1627, month: 2, day: 10, hour: 14, minute: 2, second: 18, nanoOfSecond: 1573, clock: .UTC)\nlet newDate = ZonedDateTime(year: 1627, month: 2, day: 10, hour: 14, minute: 2, second: 18, nanoOfSecond: 1574, clock: .UTC)\nlet equalDate = ZonedDateTime(year: 1627, month: 2, day: 10, hour: 14, minute: 2, second: 18, nanoOfSecond: 1573, clock: .UTC)\n\nlet isLessThan = min \u003c oldDate\nlet isGreaterThan = max \u003e newDate\nlet isLessThanOrEqual = oldDate \u003c= equalDate\nlet isGreaterThanOrEqual = oldDate \u003e= equalDate\nlet isEqual = oldDate == equalDate\nlet isLessThan = oldDate \u003c newDate\n```\n\n* Easy to manipulate. You can use our overridden operators to create / add / sub dates and times.\n\n```swift\n/// 1000-01-07T11:51:18.000001573\nlet date = LocalDateTime(\n    year: 1000,\n    month: 1,\n    day: 7,\n    hour: 11,\n    minute: 51,\n    second: 18,\n    nanoOfSecond: 1573\n)\nprint(date)\n\n/// Period(year: 1, month: 1, day: 9, hour: 2, minute: 3, second: 4, nano: 152)\nlet period = 1.year + 1.month + 1.week + 2.day + 2.hour + 3.minute + 4.second + 152.nanosecond\n\n/// 1001-03-16T13:54:22.000001725\nlet newDate = date + period\nprint(newDate)\n```\n\n\n\n## Installation\n\n### [CocoaPods](https://cocoapods.org):\n\n```ruby\npod 'AnyDate', '~\u003e 1.2.0'\n```\n\n### [Carthage](https://github.com/Carthage/Carthage):\n\n```\ngithub \"kawoou/AnyDate\" ~\u003e 1.2.0\n```\n\n### [Swift Package Manager](https://swift.org/package-manager):\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n  name: \"MyAwesomeApp\",\n  dependencies: [\n    .Package(url: \"https://github.com/kawoou/AnyDate\", majorVersion: 1),\n  ]\n)\n```\n\n### Manually\n\nYou can either simply drag and drop the `Sources` folder into your existing project.\n\n\n\n## Requirements\n\n* Swift 3.1\n* iOS 8.0+\n* tvOS 9.0+\n* macOS 10.10+\n* watchOS 2.0+\n* Virtually any platform which is compatible with Swift 3 and implements the Swift Foundation Library.\n\n\n\n\n## Changelog\n\n* 1.0.0 - 2017/08/13\n  * First release AnyDate!\n* 1.0.1 - 2017/08/16\n  * Increase test codes.\n  * Implement CustomPlaygroundQuickLookable, CustomReflectable protocols.\n* 1.0.2 - 2017/08/26\n  * Increase test codes.\n  * Support Codable protocol in swift 4.\n  * Add operators on Instant.\n* 1.0.3 - 2017/09/03\n  * Hotfix, Comparable bugs.\n* 1.0.4 - 2017/10/07\n  * Fix `Calendar(identifier: .iso8601)` crash on swift SR-3828.\n* 1.0.5 - 2018/04/11\n  * Support for Swift 4.1 and Xcode 9.3.\n* 1.0.6 - 2018/05/20\n  * Support Hashable.\n* 1.1.0 - 2018/10/18\n  * Support for Swift 4.2.\n* 1.2.0 - 2019/04/04\n  * Support for Swift 5.0.\n\n\n\n## Author\n\n* kawoou, [kawoou@kawoou.kr](mailto:kawoou@kawoou.kr)\n* dave, [dave.dev@icloud.com](mailto:dave.dev@icloud.com)\n\n\n\n## Special Thanks\n\n* Naming by 아메바\n\n\n\n## License\n\nAnyDate is under MIT license. See the LICENSE file for more info.\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkawoou%2Fanydate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkawoou%2Fanydate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkawoou%2Fanydate/lists"}