{"id":13749756,"url":"https://github.com/yannickl/YLMoment","last_synced_at":"2025-05-09T13:30:40.341Z","repository":{"id":11351581,"uuid":"13782667","full_name":"yannickl/YLMoment","owner":"yannickl","description":"Parsing, validating, manipulating, and formatting dates easily in Objective-C (API inspired by moment.js)","archived":false,"fork":false,"pushed_at":"2019-01-09T22:11:48.000Z","size":516,"stargazers_count":707,"open_issues_count":9,"forks_count":68,"subscribers_count":21,"default_branch":"master","last_synced_at":"2024-11-10T23:39:36.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://yannickl.github.io/YLMoment","language":"Objective-C","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/yannickl.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":"2013-10-22T18:53:09.000Z","updated_at":"2024-08-09T08:19:15.000Z","dependencies_parsed_at":"2022-09-13T13:12:07.827Z","dependency_job_id":null,"html_url":"https://github.com/yannickl/YLMoment","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannickl%2FYLMoment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannickl%2FYLMoment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannickl%2FYLMoment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yannickl%2FYLMoment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yannickl","download_url":"https://codeload.github.com/yannickl/YLMoment/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224863100,"owners_count":17382279,"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-08-03T07:01:11.740Z","updated_at":"2024-11-16T00:31:34.295Z","avatar_url":"https://github.com/yannickl.png","language":"Objective-C","funding_links":[],"categories":["Objective-C"],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"http://yannickloriot.com/resources/ylmoment-logo.png\" alt=\"YLMoment\" /\u003e\n\u003c/p\u003e\n\n[![License](https://cocoapod-badges.herokuapp.com/l/YLMoment/badge.svg)](http://cocoadocs.org/docsets/YLMoment/) [![Supported Platforms](https://cocoapod-badges.herokuapp.com/p/YLMoment/badge.svg)](http://cocoadocs.org/docsets/YLMoment/) [![Version](https://cocoapod-badges.herokuapp.com/v/YLMoment/badge.svg)](http://cocoadocs.org/docsets/YLMoment/) [![Build Status](https://travis-ci.org/yannickl/YLMoment.svg?branch=master)](https://travis-ci.org/yannickl/YLMoment) [![codecov](https://codecov.io/gh/yannickl/YLMoment/branch/master/graph/badge.svg)](https://codecov.io/gh/yannickl/YLMoment)\n\n***🕐 YLMoment*** is a library which provides an high abstraction level for parsing, validating, manipulating, and formatting the dates in Objective-C.\n\nIts API is inspired by the well known [moment.js](http://momentjs.com/) library, however unlike its counterpart, its core is built upon the `Foundation Framework` components (`NSDate`, `NSCalendar`, etc.) to enable the interoperability with them.\n\nThis library is designed to facilitate the manipulation of times, dates, calendars, and durations in Objective-C by providing a single, easy, and unified approach to dealing with them.\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e • \u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e • \u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e • \u003ca href=\"#contribution\"\u003eContribution\u003c/a\u003e • \u003ca href=\"#contact\"\u003eContact\u003c/a\u003e • \u003ca href=\"#license-mit\"\u003eLicense\u003c/a\u003e\n\u003c/p\u003e\n\n## Getting Started\n\nIf you want have a quick overview of the project take a look to this [blog post](http://yannickloriot.com/2013/11/handle-times-dates-calendars-and-durations-like-a-pro-in-objective-c-with-YLMoment/).\n\n## Usage\n\n### Formatting Dates\n\n```objective-c\nYLMoment *moment = [YLMoment now];\n\nNSLog(@\"%@\", [moment format:@\"MMMM dd yyyy, h:mm:ss a\"]); // October 27 2013, 10:49:48 AM\nNSLog(@\"%@\", [moment format:@\"MMM dd yy\"]);               // Oct 27 13\nNSLog(@\"%@\", [moment format:@\"yyyy 'escaped' yyyy\"]);     // 2013 escaped 2013\nNSLog(@\"%@\", [moment format]);                            // 2013-10-27T10:49:48+0100\n```\n\n### Relative Times\n\n```objective-c\nYLMoment *moment1 = [YLMoment momentWithDateAsString:@\"20111031\"];\nNSLog(@\"%@\", [moment1 fromNow]); // 2 years ago\n\nYLMoment *moment2 = [YLMoment momentWithDateAsString:@\"2012/06/20\" format:@\"yyyy/MM/dd\"];\nNSLog(@\"%@\", [moment2 fromNow]); // a year ago\n\nNSLog(@\"%@\", [[[YLMoment now] startOf:@\"day\"] fromNow]);  // 19 hours ago\nNSLog(@\"%@\", [[[YLMoment now] endOf:@\"day\"] fromNow]);    // in 5 hours\nNSLog(@\"%@\", [[[YLMoment now] startOf:@\"hour\"] fromNow]); // 11 minutes ago\n```\n\n### Time Zones\n\n```objective-c\n// Uses my current time zone: here the CET time (GMT+1)\nYLMoment *now = [YLMoment now];\nNSLog(@\"%@\", [now format]); // 2014-01-18T18:51:10+0100\n\n// Change the time zone of the moment\nnow.timeZone = [NSTimeZone timeZoneWithName:@\"GMT\"];\nNSLog(@\"%@\", [now format]); // 2014-01-18T17:51:10+0000\n\n// Convenient way to use get the UTC time\nYLMoment *utc = [YLMoment utc];\nNSLog(@\"%@\", [utc format]); // 2014-01-18T17:51:10+0000\n```\n\n### Languages\n\n`YLMoment` supports a lot of languages (see the list below) and is easy to use.\n\n```objective-c\nYLMoment *french = [[YLMoment now] addAmountOfTime:-3 forUnitKey:@\"s\"];\n[french setLocale:[NSLocale localeWithLocaleIdentifier:@\"fr_FR\"]];\nNSLog(@\"%@\", [french fromNow]); // il y a quelques secondes\n\nYLMoment *albanian = [[YLMoment now] addAmountOfTime:-3 forUnitKey:@\"s\"];\n[albanian setLocale:[NSLocale localeWithLocaleIdentifier:@\"sq_AL\"]];\nNSLog(@\"%@\", [albanian fromNow]); // disa sekonda me parë\n\nYLMoment *spanish = [[YLMoment now] subtractAmountOfTime:3 forUnitKey:@\"s\"];\n[spanish setLocale:[NSLocale localeWithLocaleIdentifier:@\"es_ES\"]];\nNSLog(@\"%@\", [spanish fromNow]); // hace unos segundos\n\nYLMoment *reference = [YLMoment momentWithArray:@[@2013]];\nYLMoment *english   = [[YLMoment now] subtractAmountOfTime:3 forUnitKey:@\"s\"];\n[english setLocale:[NSLocale localeWithLocaleIdentifier:@\"en_US\"]];\nNSLog(@\"%@\", [english fromMoment:reference]); // in 11 months\n```\n\n## Supported languages\n\nHere the list of supported languages:\n- Albanian\n- Chinese\n- Dutch\n- English\n- French\n- German\n- Italian\n- Japanese\n- Portuguese\n- Spanish\n- Vietnamese\n\nAll contribution is welcomed! ;)\n\n## Installation\n\nThe recommended approach to use _YLMoment_ in your project is using the [CocoaPods](http://cocoapods.org/) package manager, as it provides flexible dependency management and dead simple installation.\n\n### CocoaPods\n\nInstall CocoaPods if not already available:\n\n``` bash\n$ [sudo] gem install cocoapods\n$ pod setup\n```\nGo to the directory of your Xcode project, and Create and Edit your Podfile and add YLMoment:\n\n``` bash\n$ cd /path/to/MyProject\n$ touch Podfile\n$ edit Podfile\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '5.0'\n# Or platform :osx, '10.8'\npod 'YLMoment', '~\u003e 0.9.1'\n```\n\nInstall into your project:\n\n``` bash\n$ pod install\n```\n\nOpen your project in Xcode from the .xcworkspace file (not the usual project file)\n\n``` bash\n$ open MyProject.xcworkspace\n```\n\n### Manually\n\n[Download](https://github.com/YannickL/YLMoment/archive/master.zip) the project and copy the `YLMoment` folder into your project and then simply `#import \"YLMoment.h\"` in the file(s) you would like to use it in.\n\n\n## Contribution\n\nContributions are welcomed and encouraged *♡*.\n\n## Contact\n\nYannick Loriot\n - [https://21.co/yannickl/](https://21.co/yannickl/)\n - [https://twitter.com/yannickloriot](https://twitter.com/yannickloriot)\n\n## License (MIT)\n\nCopyright (c) 2013-present - Yannick Loriot\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyannickl%2FYLMoment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyannickl%2FYLMoment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyannickl%2FYLMoment/lists"}