/TimeAgoInWords

A port of rails' time_ago_in_words date method.

Primary LanguageSwiftMIT LicenseMIT

TimeAgoInWords

CI Status Version License Platform

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.