{"id":1050,"url":"https://github.com/akosma/SwiftMoment","last_synced_at":"2025-07-30T20:31:07.091Z","repository":{"id":26108314,"uuid":"29552587","full_name":"akosma/SwiftMoment","owner":"akosma","description":"A time and calendar manipulation library for  iOS 9+, macOS 10.11+, tvOS 9+, watchOS 2+ written in Swift 4.","archived":true,"fork":false,"pushed_at":"2019-01-22T11:50:53.000Z","size":250,"stargazers_count":1612,"open_issues_count":18,"forks_count":147,"subscribers_count":44,"default_branch":"master","last_synced_at":"2024-11-28T11:40:30.101Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://akosma.github.io/SwiftMoment","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akosma.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-01-20T21:17:53.000Z","updated_at":"2024-09-10T21:59:12.000Z","dependencies_parsed_at":"2022-07-09T11:30:21.631Z","dependency_job_id":null,"html_url":"https://github.com/akosma/SwiftMoment","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akosma%2FSwiftMoment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akosma%2FSwiftMoment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akosma%2FSwiftMoment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akosma%2FSwiftMoment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akosma","download_url":"https://codeload.github.com/akosma/SwiftMoment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228179160,"owners_count":17881139,"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-01-05T20:15:37.859Z","updated_at":"2024-12-04T19:32:46.647Z","avatar_url":"https://github.com/akosma.png","language":"Swift","funding_links":[],"categories":["Date \u0026 Time","Libs","Swift","Date [🔝](#readme)","Minor"],"sub_categories":["Getting Started","Date","Other free courses","Linter"],"readme":"# SwiftMoment\n\n[![Join the chat at https://gitter.im/SwiftMoment/Lobby](https://badges.gitter.im/SwiftMoment/Lobby.svg)](https://gitter.im/SwiftMoment/Lobby?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge\u0026utm_content=badge) [![Build Status](https://travis-ci.org/akosma/SwiftMoment.svg?branch=master)](https://travis-ci.org/akosma/SwiftMoment)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/SwiftMoment.svg)](https://img.shields.io/cocoapods/v/SwiftMoment)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Platform](https://img.shields.io/cocoapods/p/SwiftMoment.svg?style=flat)](http://cocoadocs.org/docsets/SwiftMoment)\n[![swiftyness](https://img.shields.io/badge/pure-swift-ff3f26.svg?style=flat)](https://swift.org/)\n\nThis framework is inspired by [Moment.js](http://momentjs.com). Its\nobjectives are the following:\n\n- Simplify the manipulation and readability of date and interval values.\n- Provide help when parsing dates from various string representations.\n- Simplifying the formatting of date information into strings.\n- Streamlining getting date components (day, month, etc.) from dates and\n  time intervals.\n\nImportant: This framework supports iOS 9+, macOS 10.11+, tvOS 9+, watchOS 2+, Xcode 8 and Swift 3.\n\n## Installation\n\nSwiftMoment is compatible with\n[Carthage](http://github.com/Carthage/Carthage) and\n[CocoaPods](http://cocoapods.org/). With CocoaPods, just add this to\nyour Podfile:\n\n```ruby\npod 'SwiftMoment'\n```\n\nSwiftMoment can also be used via the [Swift Package Manager](https://swift.org/package-manager/). \nJust add it to the dependencies in your Package.swift file:\n\n```Swift\nlet package = Package(\n    name: \"MyPackage\",\n    dependencies: [\n        ...\n        .package(url: \"https://github.com/akosma/SwiftMoment.git\", from: \"0.7.1\"),\n    ],\n    ...\n)\n```\n\n\n## Mac OS X Notes\n\n- Drag the created .framework file into the Xcode Project, be sure to tick 'Copy Files to Directory'\n- In the containing applications target, add a new 'Copy File Build Phase'\n- Set the 'Destination' to 'Frameworks'\n- Drag in the created .framework\n\n## Examples\n\nTo use this library, just `import SwiftMoment` in your application.\n\nTo create new moment instances:\n\n```Swift\nlet now = moment()\nlet yesterday = moment(\"2015-01-19\")\n```\n\nBy default, moments are initialized with the current date and time. You\ncan create moments for any... moment in the future or the past; you can\ndo that by passing strings in different formats:\n\n```Swift\nlet yesterday = moment(\"2015-01-19\")\n```\n\nYou can also do it by directly specifying the components manually:\n\n```Swift\nlet today = moment([2015, 01, 19, 20, 45, 34])\n```\n\nYou can also use a dictionary with the following keys:\n\n```Swift\nlet obj = moment([\"year\": 2015,\n                    \"second\": 34,\n                    \"month\": 01,\n                    \"minute\": 45,\n                    \"hour\": 20,\n                    \"day\": 19\n                ])\n```\n\nWhen using a `[String: Int]` dictionary, the order of the keys does not\nmatter. Moreover, only the keys above are taken into account, and any\nother information is ignored.\n\nThere is also an extension to the `Int` type in Swift, used to create\n`Duration` values directly from an integer value:\n\n```Swift\nlet duration = 5.hours + 56.minutes\n```\n\n## Architecture\n\nThe two most important components of this library are the `Moment` and\n`Duration` structures. `Moment` wraps an `NSDate` instance, while\n`Duration` wraps an `NSTimeInterval` value.\n\nBoth `Moment` and `Duration` comply with the `Comparable` protocols, and\ninclude all the required operators. In addition, `Moment` instances can\nbe subtracted from one another (which yields a `Duration`) and\n`Duration` instances can be added to `Moments` to create new moments.\n\n`Moments` and `Durations` are made as immutable as possible.\n\n## Tests\n\nSwift Moment includes a suite of tests showing how to use the different\nfunctions of the framework.\n\nTo run the Linux tests in a macOS environment, please use the included Dockerfile:\n\n```\ndocker build --tag swiftmoment .\ndocker run --rm swiftmoment\n```\n\n## Playground\n\nA playground is included in the project to learn how to use the library.\n\n## Differences with [Moment.js](http://momentjs.com)\n\n- Format strings `DD` and `dd` do not yield the same results.\n\n## Contributors\n\nLots of people are actively helping in the development of this library;\nplease check the\n[CONTRIBUTORS](https://github.com/akosma/SwiftMoment/blob/master/CONTRIBUTORS.md)\nfile for the full list! Thanks to all :)\n\n## License\n\nThis project is distributed under a BSD license. See the LICENSE file\nfor details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakosma%2FSwiftMoment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakosma%2FSwiftMoment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakosma%2FSwiftMoment/lists"}