My (main) usecase: I have a sort-of timeline formatted by a jinja2 macro. The job of the macro is to format the entries in some nice way (FSVO nice) including formatting dates in a human-friendly way (and annotated for machines). The data entry on the other hand is via calls to this macro: Here, I would like to use a machine-friendly date format and not hardcode another human friendly version, hence I would like to feed the machine-friendly format in the macro into datetime_format and get out the human friendly version I desire (at the moment. If I change my mind its a single line change).
So the macro might include something like this: <time datetime="{{ starttime }}">{{ starttime | datetime_format('%Y<br/>%b')|safe }}</time> where starttime is 2018-06-03 13:51+0200.
Dealing with hardcoded datestrings is perhaps a bit specialcasey (but easy enough, so I propose it anyway), but allowing arbitrary format strings seems like something nice to have if you don't believe in standards.
My (main) usecase: I have a sort-of timeline formatted by a jinja2 macro. The job of the macro is to format the entries in some nice way (FSVO nice) including formatting dates in a human-friendly way (and annotated for machines). The data entry on the other hand is via calls to this macro: Here, I would like to use a machine-friendly date format and not hardcode another human friendly version, hence I would like to feed the machine-friendly format in the macro into
datetime_format
and get out the human friendly version I desire (at the moment. If I change my mind its a single line change).So the macro might include something like this:
<time datetime="{{ starttime }}">{{ starttime | datetime_format('%Y<br/>%b')|safe }}</time>
wherestarttime
is2018-06-03 13:51+0200
.Dealing with hardcoded datestrings is perhaps a bit specialcasey (but easy enough, so I propose it anyway), but allowing arbitrary format strings seems like something nice to have if you don't believe in standards.