Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Before I start hacking on this myself... anyone have a Ruby method to produce this?
# return strings like:
# "3 months and 14 days" until"...
# "1 year and 11 days until"...
def time_until_in_words(future_date)
future_date -
# magic!

This comment has been minimized.

Copy link

rubysolo commented Jun 29, 2011

What about this?

def time_until_in_words
  "#{ distance_of_time_in_words(, future_date) } until"

This comment has been minimized.

Copy link
Owner Author

robbyrussell commented Jun 29, 2011

cheeky ;-)

i need very specific dates... not ending it with "about" or "less than"

looks like i'll have to hack on a custom method :-)


This comment has been minimized.

Copy link

dmarkow commented Jun 29, 2011

The dotiw gem will do this. It overrides the default distance_of_time_in_words method.

distance_of_time_in_words(, future_date, false, :only => ["years", "months", "days"])
#=> "3 months and 14 days"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.