Keats / tera

A template engine for Rust based on Jinja2/Django
http://keats.github.io/tera/
MIT License
3.54k stars 283 forks source link

Using Milliseconds Timestamp for `date()` or Reformating existing Timestamp #755

Closed DK26 closed 2 years ago

DK26 commented 2 years ago

Hi there!

I have a use case where I can receive a timestamp either in string format that isn't ISO formatted, or as a milliseconds epoch timestamp.

The date() function seem to accept only ISO format or an epoch in seconds timestamps.

Is there a way for me to use a milliseconds timestamp in conjunction with the date() function or reformat the existing Timestamp, using Tera, but avoiding custom functions?

DK26 commented 2 years ago

Well.. foolish me 😅

I totally forgot I can manipulate the data:

{{ my_miliseconds_timestamp / 1000 | int | date( . . . ) }}