Adds filters for datetime functions.#258
Conversation
Codecov Report
@@ Coverage Diff @@
## master #258 +/- ##
============================================
+ Coverage 71.89% 71.95% +0.06%
- Complexity 1408 1437 +29
============================================
Files 221 226 +5
Lines 4433 4514 +81
Branches 705 717 +12
============================================
+ Hits 3187 3248 +61
- Misses 1004 1014 +10
- Partials 242 252 +10
Continue to review full report at Codecov.
|
|
Do these have any precedent in Jinja? I would prefer to keep it as compatible as possible. If not, perhaps these could filters could be named with a little more descriptively like |
|
The recommended way in jinja is with python commands. We could encourage developers to use Java methods like |
boulter
left a comment
There was a problem hiding this comment.
Looks good. Can you document the temporal unit values in each filter's docs?
|
I changed this to support all ChronoUnit enum values and added a link at the top of each class. |
Adds
plus_time,minus_time, andbetween_timesfilters to operate on datetime objects/timestamp. Examples:date|plus_time('1', 'days')will give you a date 1 day in the future;begin|between_times(end, 'minutes')will give you the number of minutes between those two dates.I also added a
strtotimeto convert a string and datetime format to a datetime object. For example,"2018-07-14T14:31:30+0530"|strtotime("yyyy-MM-dd'T'HH:mm:ssZ")|unixtimestampwill output1531558890000Fixes #56