CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

TimeAgoInWords 3.0.0

TimeAgoInWords 3.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Dec 2016
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Colin T.A. Gray, Sean Dougherty, Ryan Boyajian.



  • By
  • Ello and Ryan Boyajian

TimeAgoInWords

This is a direct port of: http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html#method-i-distance_of_time_in_words

Usage

To override the default strings you can update them before you access them:

let railsStrings = [
  "LessThan": "less than ",
  "About": "about ",
  "Over": "over ",
  "Almost": "almost ",
  "Seconds": " seconds",
  "Minute": " minute",
  "Minutes": " minutes",
  "Hour": " hour",
  "Hours": " hours",
  "Day": " day",
  "Days": " days",
  "Months": " months",
  "Years": " years",
]
TimeAgoInWordsStrings.updateStrings(railsStrings)
NSDate(timeIntervalSinceNow: -90).timeAgoInWords() // 2 minutes

Installation

TimeAgoInWords is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "TimeAgoInWords"

License

TimeAgoInWords is available under the MIT license. See the LICENSE file for more info.