Do date formatting for history view server side for consistency.

This commit is contained in:
Chase Sterling 2016-07-09 20:10:46 -04:00
parent bc0876cf33
commit 15924df4e2
2 changed files with 4 additions and 6 deletions

View file

@ -1,5 +1,6 @@
import itertools import itertools
import sys import sys
from datetime import datetime
from flask import abort, g, render_template, request, redirect, Blueprint, flash, url_for, current_app 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 flask.ext.login import login_required, current_user
from realms.lib.util import to_canonical, remove_ext, gravatar_url from realms.lib.util import to_canonical, remove_ext, gravatar_url
@ -80,6 +81,8 @@ def history_data(name):
for item in items: for item in items:
item['gravatar'] = gravatar_url(item['author_email']) item['gravatar'] = gravatar_url(item['author_email'])
item['DT_RowId'] = item['sha'] 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 total_records, hist_complete = page.history_cache
if not hist_complete: if not hist_complete:
# Force datatables to fetch more data when it gets to the end # Force datatables to fetch more data when it gets to the end

View file

@ -64,12 +64,7 @@
} }
}, },
{ "data": "message" }, { "data": "message" },
{ "data": "time", { "data": "date" }
"render": function (data) {
var date = new Date(data * 1000);
return date.toDateString();
}
}
], ],
rowCallback: function( row, data, index ) { rowCallback: function( row, data, index ) {
index += $('.dataTable').DataTable().page.info().start; index += $('.dataTable').DataTable().page.info().start;