Created
June 29, 2011 19:59
-
-
Save robbyrussell/1054781 to your computer and use it in GitHub Desktop.
Before I start hacking on this myself... anyone have a Ruby method to produce this?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# return strings like: | |
# "3 months and 14 days" until"... | |
# "1 year and 11 days until"... | |
# | |
def time_until_in_words(future_date) | |
future_date - Date.today | |
# magic! | |
end |
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 :-)
The dotiw
gem will do this. It overrides the default distance_of_time_in_words
method. http://rubydoc.info/gems/dotiw/1.1.0/frames
distance_of_time_in_words(Time.now, 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
What about this?