From 15924df4e2dfa1481a513dbc13de58b4610a7a68 Mon Sep 17 00:00:00 2001 From: Chase Sterling Date: Sat, 9 Jul 2016 20:10:46 -0400 Subject: [PATCH] Do date formatting for history view server side for consistency. --- realms/modules/wiki/views.py | 3 +++ realms/templates/wiki/history.html | 7 +------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/realms/modules/wiki/views.py b/realms/modules/wiki/views.py index 98d586d..765a3ab 100644 --- a/realms/modules/wiki/views.py +++ b/realms/modules/wiki/views.py @@ -1,5 +1,6 @@ import itertools import sys +from datetime import datetime from flask import abort, g, render_template, request, redirect, Blueprint, flash, url_for, current_app from flask.ext.login import login_required, current_user from realms.lib.util import to_canonical, remove_ext, gravatar_url @@ -80,6 +81,8 @@ def history_data(name): for item in items: item['gravatar'] = gravatar_url(item['author_email']) item['DT_RowId'] = item['sha'] + date = datetime.fromtimestamp(item['time']) + item['date'] = date.strftime(current_app.config.get('DATETIME_FORMAT', '%b %d, %Y %I:%M %p')) total_records, hist_complete = page.history_cache if not hist_complete: # Force datatables to fetch more data when it gets to the end diff --git a/realms/templates/wiki/history.html b/realms/templates/wiki/history.html index ff8747a..1d50aec 100644 --- a/realms/templates/wiki/history.html +++ b/realms/templates/wiki/history.html @@ -64,12 +64,7 @@ } }, { "data": "message" }, - { "data": "time", - "render": function (data) { - var date = new Date(data * 1000); - return date.toDateString(); - } - } + { "data": "date" } ], rowCallback: function( row, data, index ) { index += $('.dataTable').DataTable().page.info().start;