Module: DateTimeAgoInWords

Included in:
ActiveSupport::TimeWithZone
Defined in:
lib/devlog/date_time_ago_in_words.rb

Instance Method Summary collapse

Instance Method Details

#ago_in_wordsObject



4
5
6
7
8
9
10
11
12
# File 'lib/devlog/date_time_ago_in_words.rb', line 4

def ago_in_words
  return 'a very very long time ago' if self.year < 1800
  secs = Time.now - self
  return 'just over' if secs > -1 && secs < 1
  return 'now' if secs <= -1
  pair = ago_in_words_pair(secs)
  ary = ago_in_words_singularize(pair)
  ary.size == 0 ? '' : ary.join(' and ') << ' ago'
end