Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"diffMax" filter additon #116

Open
wants to merge 3 commits into
base: master
from

Conversation

@etshy
Copy link

commented Mar 3, 2019

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)

Squashed commit of the following:
commit 095b449
Author: Etshy <garbuio.jonas@gmail.com>
Date:   Sun Mar 3 02:22:17 2019 +0100

    return date to be able chain maxdiff filter with ago filter

commit da2f0b1
Author: Etshy <garbuio.jonas@gmail.com>
Date:   Sun Mar 3 02:08:00 2019 +0100

    Fix first argument

commit 084be7b
Author: Etshy <garbuio.jonas@gmail.com>
Date:   Sun Mar 3 01:52:15 2019 +0100

    Add a maxdiff filter to set a maximum to the "ago" formatting

@etshy etshy changed the title Squashed commit of the following: "diffMax" filter additon Mar 3, 2019

@etshy

This comment has been minimized.

Copy link
Author

commented Mar 4, 2019

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 added some commits Mar 4, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.