Convert dates to EST for display on PromotedLinkTraffic.

This commit is contained in:
bsimpson63
2013-04-04 13:59:08 -04:00
parent 6a67f2f11c
commit 2e0923ea6a
3 changed files with 15 additions and 5 deletions

View File

@@ -23,11 +23,13 @@
import collections
import datetime
import pytz
import urllib
from pylons.i18n import _
from pylons import g, c, request
import babel.core
from babel.dates import format_datetime
from r2.lib import promote
from r2.lib.menus import menu
@@ -526,7 +528,15 @@ class PromotedLinkTraffic(RedditTraffic):
self.total_impressions += imps
self.total_clicks += clicks
computed_history.append((date, data + (u_ctr, ctr)))
date = date.replace(tzinfo=pytz.utc)
datestr = format_datetime(
date,
tzinfo=pytz.timezone("US/Eastern"),
locale=c.locale,
format="yyyy-MM-dd HH:mm zzz",
)
computed_history.append((date, datestr, data + (u_ctr, ctr)))
self.history = computed_history

View File

@@ -84,9 +84,9 @@
</tr>
</thead>
<tbody>
% for date, data in thing.history:
% for date, datestr, data in thing.history:
<tr>
<th scope="col" data-value="${js_timestamp(date)}">${date}</th>
<th scope="col" data-value="${js_timestamp(date)}">${datestr}</th>
% for datum in data:
<td data-value="${datum}">${format_number(datum)}</td>
% endfor

View File

@@ -67,9 +67,9 @@
</tr>
</thead>
<tbody>
% for date, data in thing.history:
% for date, datestr, data in thing.history:
<tr>
<th scope="col" data-value="${js_timestamp(date)}">${date}</th>
<th scope="col" data-value="${js_timestamp(date)}">${datestr}</th>
% for datum in data:
<td data-value="${datum}">${format_number(datum)}</td>
% endfor