Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

distance_of_time_in_words / time_ago_in_words shouldn't use named arguments

#6522

In contrast to most other view helpers, distance_of_time_in_words and time_ago_in_words still use a named argument (include_seconds). I propose to get things in line with the rest and pass :include_seconds => true/false as part of an options hash.

# old
distance_of_time_in_words(19.seconds.ago, Time.current, true) # => less than 20 seconds
time_ago_in_words(19.seconds.ago, true) # => less than 20 seconds

# new
distance_of_time_in_words(19.seconds.ago, Time.current, :include_seconds => true) # => less than 20 seconds
time_ago_in_words(19.seconds.ago, :include_seconds => true) # => less than 20 seconds

Although there's a little more typing, I'd argue that it's less surprising.

A patch is attached. All tests are green and the patch also adds new tests (same as the old ones with just the argument swapped out for a hash). I've also updated the documentation and added a deprecation warning.

Reported by Clemens Kofler · March 4th, 2011 @ 04:45 PM

State: open
Milestone: 3.x
Assigned to: Santiago Pastorino Santiago Pastorino
Importance: Low

Activity

  1. Dan Pickett
    Dan Pickett
    • Milestone set to 3.x
    • Assigned user set to Dan Pickett
    • Importance changed from to Low

    I'm +1 on this and it applies cleanly to master, but it creates a lot of noise in the test suite currently. Can you update the test suite to comply with your new contract?

    March 13th, 2011 @ 05:32 PM

  2. Clemens Kofler
    Clemens Kofler

    Sure – I just left the old tests untouched to ensure things still work. They are removed in the attached patch. I've also rebased against the current master.

    March 13th, 2011 @ 09:24 PM

  3. Dan Pickett
    Dan Pickett
    • State changed from new to open
    • Assigned user changed from Dan Pickett to Santiago Pastorino

    a model patch. Applies cleanly to master and appears well documented.

    Thanks Clemens. Assigning to Santiago for his review and signoff.

    March 14th, 2011 @ 04:09 PM

  4. Clemens Kofler
    Clemens Kofler

    Any news on that one? Not that there's any time pressure on it but I don't want it to become stale. :)

    May 2nd, 2011 @ 03:57 PM