fabpot/Twig — Issue #571: Enable easier date comparisons
Author: Seldaek
Created: 2011-12-26 13:33:10+00:00
State: open

Right now if you have a string containing a date in whatever format, to know if it's a past or future date for example you have to do:

```jinja
{% if item.date|date('U') < 'now'|date('U') %}
```

That creates two DateTime instances and then formats them and then compares the values. You can't really omit the `('U')` since the default format doesn't really do comparisons well.

Two options for improvements:

- Add a `datetime` filter or such that returns the unformatted DateTime, then they can be compared
- Add some date specific tests (`is older than`?), but those to also support `<=` and such it'll be a bit verbose