KnpTimeBundle icon indicating copy to clipboard operation
KnpTimeBundle copied to clipboard

"diffMax" filter additon

Open etshy opened this issue 7 years ago • 1 comments

close #78

Addition of a "maxdiff" filter (I had no idea to name it, if you have a better name, let me know) to limit the Date difference to display the "ago" format.

I made that PR quickly because I wanted to have that behaviour in an app and had no idea how to do that in twig only and i saw a related issue.

It's one of my first PR for an open source project, so if there's any problem with the PR (code or this description), let me know.

Examples: (in french, sorry. For non-french, It says "5 hours ago") with the code {{ chapter.publishedAt|diffmax(15, 'd/m/Y', 'hour')|ago }} ~~(The filters order doesn't seem to matter)~~ (The filter order matter, the diffmax HAVE TO be prior the ago one)

etshy avatar Mar 03 '19 01:03 etshy

seems like the tests failed because of the (clone $now) in the tests.

I'll change that soon.

edit : Didn't remember I used (clone $datetime) in the code too... I'll fix that in few hours.

etshy avatar Mar 04 '19 12:03 etshy