Skip to content

Conversation

@etshy
Copy link

@etshy etshy 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)

commit 095b449
Author: Etshy <[email protected]>
Date:   Sun Mar 3 02:22:17 2019 +0100

    return date to be able chain maxdiff filter with ago filter

commit da2f0b1
Author: Etshy <[email protected]>
Date:   Sun Mar 3 02:08:00 2019 +0100

    Fix first argument

commit 084be7b
Author: Etshy <[email protected]>
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
Copy link
Author

etshy 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: configuration to limit the ago return by a certain time diff

1 participant