-
Notifications
You must be signed in to change notification settings - Fork 169
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
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_times
filters 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
strtotime
to 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")|unixtimestamp
will output1531558890000
Fixes #56