From eef6e081eaf6834c1da2076e1726c349f605d494 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 01 2014 10:35:19 +0000 Subject: Add a new template filter to convert unix timestamp to a date/time representation --- diff --git a/progit/__init__.py b/progit/__init__.py index 36d003a..cc1999b 100644 --- a/progit/__init__.py +++ b/progit/__init__.py @@ -14,6 +14,7 @@ import pkg_resources __version__ = '0.1' +import datetime import logging import os import subprocess @@ -236,6 +237,14 @@ def rst2html(rst_string): return progit.doc_utils.convert_doc(unicode(rst_string)) +@APP.template_filter('format_ts') +def format_ts(string): + """ Template filter transforming a timestamp to a date + """ + dt = datetime.datetime.fromtimestamp(int(string)) + return dt.strftime('%b %d %Y %H:%M:%S') + + @APP.template_filter('format_loc') def format_loc(loc, commit=None, prequest=None): """ Template filter putting the provided lines of code into a table