Add datetime_fmt-arg to tsstats.template.render_template

Specify a custom datetime-format for various datetime-renderings (creation-time, last
online)
This commit is contained in:
Thor77 2016-09-17 22:38:30 +02:00
parent bd2157c2b8
commit 1ecf24b9b2
1 changed files with 2 additions and 2 deletions

View File

@ -12,7 +12,7 @@ logger = logging.getLogger('tsstats')
def render_template(clients, output, title='TeamspeakStats',
template_path='template.html'):
template_path='template.html', datetime_fmt='%x %X %Z'):
'''
render template with `clients`
@ -55,7 +55,7 @@ def render_template(clients, output, title='TeamspeakStats',
def frmttime(timestamp):
if not timestamp:
return ''
return timestamp.strftime('%x %X %Z')
return timestamp.strftime(datetime_fmt)
template_env.filters['frmttime'] = frmttime
template = template_env.get_template(template_path)
with open(output, 'w') as f: