{"id":13489235,"url":"https://github.com/remirobert/Tempo","last_synced_at":"2025-03-28T04:30:58.879Z","repository":{"id":24765370,"uuid":"28178583","full_name":"remirobert/Tempo","owner":"remirobert","description":":watch: Date and time manager for iOS/OSX written in Swift","archived":false,"fork":false,"pushed_at":"2015-05-27T12:54:43.000Z","size":318,"stargazers_count":151,"open_issues_count":3,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-20T18:23:06.060Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://remirobert.github.io/Tempo","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/remirobert.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":"2014-12-18T10:16:00.000Z","updated_at":"2024-12-18T11:57:14.000Z","dependencies_parsed_at":"2022-07-24T03:00:05.041Z","dependency_job_id":null,"html_url":"https://github.com/remirobert/Tempo","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FTempo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FTempo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FTempo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/remirobert%2FTempo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/remirobert","download_url":"https://codeload.github.com/remirobert/Tempo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245970381,"owners_count":20702398,"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-07-31T19:00:20.746Z","updated_at":"2025-03-28T04:30:58.563Z","avatar_url":"https://github.com/remirobert.png","language":"Swift","funding_links":[],"categories":["Libs","Date \u0026 Time","Swift"],"sub_categories":["Date"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src =\"https://raw.githubusercontent.com/remirobert/Tempo/master/tempoExample/benner.png\"/\u003e\n\u003c/p\u003e\n\u003c/br\u003e\n\nTempo was designed to work both in OSX and in iOS (7.0+).\nWork with the time or dates can be cumbersome, iOS development. Tempo allows you to deal easly with date and time.\nBasics manipulations are already implemented in Tempo.\n\nHow to use it ?\n===============\n\nYou can build a new Tempo, with severals way:\n\n```Swift\nvar birthdayTempo = Tempo { (newTemp) -\u003e () in\n    newTemp.years = 2014\n    newTemp.months = 12\n    newTemp.days = 12\n}\nvar currentTime = Tempo()\nvar tempoWithDate = Tempo(date: customNSDate)\nvar tempoWithString = Tempo(stringDate: \"12/02/1992\")\nvar tempoCustomFormat = Tempo(stringDate: \"12/02/1992\", \"dd/MM/yyyy\")\n```\n\nConvert Tempo to string, with specific format:\nAll the basics format work with Tempo.\n\n```Swift\nTempo().format()                                // \"2014 12 12 00:00:00\"\nTempo().format(\"yyyy MM dd\")                    // \"2014 12 12\"\nTempo().format(\"dd EE / MMMM / yyyy\")           // \"12 Fri / December / 2014\"\n\nlet t1 = Tempo(stringDate: \"2014 12 12\")\n\n//change the locale date\nt1.locale = NSLocale(localeIdentifier: \"fr_FR\")\nt1.format(format: \"EEEE\")                       // \"mercredi\"\n\nt1.locale = NSLocale(localeIdentifier: \"en_EN\")\nt1.format(format: \"EEEE\")                       // \"Wednesday\"\n\nt1.locale = NSLocale(localeIdentifier: \"es_ES\")\nt1.format(format: \"EEEE\")                       // \"miércoles\"\n```\n\nWith Tempo you have access to the date components and the date itself:\nThe date components and the date are linked.\n\n```Swift\nlet t = Tempo()\n\nt.years! += 1\nt.days! += 20\n\nt.date = NSDate()\n```\n\nYou can also make simple comparaison between two Tempo or with NSDate:\n\n```Swift\nvar newDate = Tempo { (newTemp) -\u003e () in\n  newTemp.years = 2014\n  newTemp.months = 10\n  newTemp.days = 12\n  newTemp.minutes = 2\n}\n\nprintln(\"newDate: \\(newDate.formatDate())\")             // \"2014 10 12 00:02:00\"\nprintln(\"current time : \\(Tempo().formatDate())\")       // \"2014 12 18 15:40:11\"\n\nTempo().isAfter(newDate)                                // \"True\"\nTempo().isBefore(newDate)                               // \"False\"\nTempo().isSame(newDate)                                 // \"False\"\nTempo().isBetween(tempoLeft:newDate, tempoRight:d2)     // \"True\"\n\nTempo().isToday(newDate)                                // \"False\"\nTempo().isThisMonth(newDate)                            // \"true\"\nTempo().isThisYear(newDate)                             // \"true\"\n```\n\nTempo also override operator the simple comparaison :\n\n```Swift\n\n// same as tempo1.isBefore(tempo2)\nif tempo1 \u003c tempo2 {\n}\n\n// same as tempo1.isAfter(tempo2)\nif tempo1 \u003e tempo2 {\n}\n\n// same as tempo1.isSame(tempo2)\nif tempo1 == tempo2 {\n}\n\n// You can add two tempo together:\nlet result: Tempo = tempo1 + tempo2\nlet result: Tempo = tempo1 - tempo2\n```\n\nKnow difference between two date component:\n\n```Swift\nvar newDate = Tempo { (newTemp) -\u003e () in\n  newTemp.years = 2014\n  newTemp.months = 10\n  newTemp.days = 12\n  newTemp.minutes = 2\n}\n\nTempo().diffYear(newDate)                  // \"0\"\nTempo().diffMonth(newDate)                // \"-4\"\nTempo().diffWeek(newDate)                // \"-18\"\nTempo().diffDay(newDate)                // \"-130\"\n```\n\nGet time ago from date or current time:\nReturn literal string with the difference between two Tempo. Can be usefull in for display in message or feeds.\nYou have three diferent kind of display.\n\n```Swift\nvar date = Tempo { (newTemp) -\u003e () in\n    newTemp.years = 2014\n    newTemp.months = 10\n    newTemp.days = 25\n}\n\n// Classic display\ndate.timeAgoNow()                       // \"3 months ago\"\ndate.timeAgo(Tempo())\n\n// Short display\ndate.timeAgoSimpleNow()                 // \"3mo\"\ndate.timeAgoSimple(Tempo())\n\n// More readable display\ndate.dateTimeUntilNow()                 // \"This year\"\ndate.dateTimeUntil(Tempo())\n```\n\nLicense\n=======\n\n```\nThe MIT License (MIT)\nCopyright (c) 2014 rémi ROBERT\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 all\ncopies 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 THE\nSOFTWARE.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremirobert%2FTempo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fremirobert%2FTempo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fremirobert%2FTempo/lists"}