silverstripe/silverstripe-framework — pull request #3025 by tractorcow (2014-04-10 23:50:26+00:00)
Title: API DateTime.Ago better infers significance of date units.

BUG Fixes missing i18n translation in Date::TimeDiffIn
BUG Fixes Date::TimeDiffIn not respecting mocked SS_Datetime::now

This fix provides more meaningful representations of time periods. E.g. "36 days" has a lot more relevant that "1 month". By default the minimum significant number of units is 2, but can be tweaked by customising the second parameter.

`Date::TimeDiffIn` has been cleaned up, with support for i18n strings included (which have been missing for ages), as well as cleanup of duplicate code.

Although this was raised as a usability issue in 3.1, this is an api change and can probably wait until 3.2. I can port back part of this as a bugfix to 3.1 if someone feels these issues deserve fixing there too.

There was a note in the prior code regarding translation strings having spaces in them, but I didn't notice any after a check of all current strings, so I think that issue has been safely resolved since then. :) I've thus removed the fix hack for this.

(ref: CWPBUG-141)