distance_of_time_in_words_to_now

Hi There,

As I have learned the hard way, let me discuss my question, idea or feature here before doing actual work on it…

distance_of_time_in_words_to_now() seems to be unable to tell if this distance is in the future or in the past.

I’d really like to see ‘in 5 days’ or ‘5 days ago’ depending on, well, if it was 5 days ago or will be in 5 days.

I’ve googled and saw some gems, one by Radar, but I think this seemingly simple thing shouldn’t be in a gem.

I’d be happy to hear your comments.

Cheers

Ace

I support this. I just don’t think it should be the only way — there should be an option to set if we’re just interested in distance (z days), or if we’re interested in one with regard to whether it was in past or will be in the future (in x days, y days ago).

Cheers,

Gosha Arinich

I have this now

module ActionView::Helpers::DateHelper

def distance_of_time_in_words_to_now_with_future(from_time, include_seconds = false) if from_time > Time.now() ‘in ’ + distance_of_time_in_words_to_now_without_future(from_time, include_seconds) else distance_of_time_in_words_to_now_without_future(from_time, include_seconds) + ’ ago’ end end

alias_method_chain :distance_of_time_in_words_to_now, :future

end

You don’t take i18n into account.

Additionally, I would not use method chain or so for this. Instead, I would just modify distance_of_time_in_words_to_now to handle additional boolean option called :relative, and just handle it.

Cheers,

Gosha Arinich

Agree, I am just showing what kind of thing works now and how I'd like it to be more like you pointed out.