Module: ParlezHelper

Defined in:
app/helpers/parlez_helper.rb

Instance Method Summary collapse

Instance Method Details

#published_at_in_words(dt) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/parlez_helper.rb', line 3

def published_at_in_words(dt)
  out = ""
  distance = distance_of_time_in_words_to_now(dt)
  long_ordinal = dt.to_formatted_s(:long_ordinal)
  if dt.future?
    out << 'Will be published ' << ((dt > 1.day.from_now) ? "on #{long_ordinal}" : "in #{distance}")
  else
    out << 'Was published ' << ((dt < 1.day.ago) ? "on #{long_ordinal}" : "#{distance} ago")
  end
end