fuel/core — Issue #624: Improve \Date::time_ago method by letting specify return units
Author: darklow
Created: 2011-10-29 06:18:45+00:00
State: open

First of all
\Date::time_ago is very useful method. I used it a lot in my project. However there is one thing.

If you want to use this method to calculate the age of a person (which is quite often operation for different kind of a projects).
This method returns time in decades, which is correctly, however not quite nice and not the unit as we are used to count our age.

There are also lot of cases when we would like to calculate difference time, but need specific units and not auto units.

Whit very small adjustment by letting specify specific unit as third argument for this method could get this method significantly more useful.

2) One more idea for improvement. If you agree on my previous suggestion about extra argument, then sometimes we need just the difference number without the trailing text " years ago", Therefore maybe the best improvement is totally new method, something like
time_ago_diff() where we could specify the same two arguments as for time_ago() method and also third one - units in which we would like to return difference. By adding this method we could leave time_ago() method unchanged.... or even time_ago method could use time_ago_diff() for calulations.