Fixes and enhancements to the date filter #107

merged 1 commit into from Jan 6, 2017


None yet

2 participants


No description provided.

@@ -350,7 +350,7 @@ impl Tera {
self.register_filter("pluralize", number::pluralize);
self.register_filter("round", number::round);
self.register_filter("filesizeformat", number::filesizeformat);
- self.register_filter("filesizeformat", number::date);
+ self.register_filter("date", number::date);
Keats Jan 4, 2017 Owner

ah <_<

+/// Input can be an i64 timestamp (seconds since epoch) or an RFC3339 string
+/// (default serialization format for chrono::DateTime).
/// Time formatting syntax is inspired from strftime and a full reference is available
/// on [chrono docs](
pub fn date(value: Value, args: HashMap<String, Value>) -> Result<Value> {
Keats Jan 4, 2017 Owner

since that now works on both number and string, can you put it in and use pattern matching on the value like in that file?

Keats commented Jan 4, 2017

Thanks, facepalm for the registration of the date filter


Will make the changes as requested and resubmit - it might take me a couple of days as I've quite a bit on.

If you want the registration fix immediately, feel free to cherry pick it or re-implement and I'll rebase.

@philwhineray philwhineray Add RFC3339 format support to the date filter
Should allow, for example, direct use of chrono::DateTime as context
arguments, since RFC3339 is their default serialization format.

Moved the date function into and use pattern matching to
extract a local date before formatting.

Hopefully this is what you had in mind

Keats commented Jan 6, 2017

Looks good, thanks!

@Keats Keats merged commit 813c830 into Keats:master Jan 6, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment