diff --git a/r2/r2/lib/utils/utils.py b/r2/r2/lib/utils/utils.py index e1cd57330..482d459c9 100644 --- a/r2/r2/lib/utils/utils.py +++ b/r2/r2/lib/utils/utils.py @@ -319,6 +319,8 @@ def trunc_time(time, mins, hours=None): second = 0, microsecond = 0) +def long_datetime(datetime): + return datetime.ctime() + " GMT" def median(l): if l: diff --git a/r2/r2/templates/comment.html b/r2/r2/templates/comment.html index d2b3477af..4d47ec47a 100644 --- a/r2/r2/templates/comment.html +++ b/r2/r2/templates/comment.html @@ -26,6 +26,7 @@ from r2.lib.pages import WrappedUser %> +<%namespace file="utils.html" import="timestamp" /> <%inherit file="comment_skeleton.html"/> ##################### @@ -95,8 +96,7 @@ ${parent.collapsed()} %if show: ${unsafe(self.score(thing, likes = thing.likes))} %endif - ## thing.timesince is a cache stub - ${unsafe(_("%(timeago)s ago") % dict(timeago=thing.timesince))} + ${timestamp(thing, thing.timesince)} ${_("ago")} %if thing.editted: *  %endif diff --git a/r2/r2/templates/link.html b/r2/r2/templates/link.html index cbd180fca..67ae9e45c 100644 --- a/r2/r2/templates/link.html +++ b/r2/r2/templates/link.html @@ -29,7 +29,7 @@ %> <%inherit file="printable.html"/> -<%namespace file="utils.html" import="plain_link" /> +<%namespace file="utils.html" import="plain_link, timestamp" /> <%namespace file="printablebuttons.html" import="toggle_button" /> <%def name="numcol()"> @@ -214,8 +214,8 @@ ${parent.thing_css_class(what)} ${"over18" if thing.over_18 else ""} ${unsafe(taglinetext % dict(reddit = self.subreddit(), score = capture(self.score, thing, thing.likes, tag='span'), - when = thing.timesince, - author= WrappedUser(thing.author, thing.attribs, thing).render()))} + when = capture(timestamp, thing, thing.timesince), + author = WrappedUser(thing.author, thing.attribs, thing).render()))} diff --git a/r2/r2/templates/profilebar.html b/r2/r2/templates/profilebar.html index a83bd999a..e842f6768 100644 --- a/r2/r2/templates/profilebar.html +++ b/r2/r2/templates/profilebar.html @@ -24,9 +24,8 @@ import locale from r2.lib.filters import edit_comment_filter, unsafe, safemarkdown from r2.lib.template_helpers import static - from r2.lib.utils import timesince %> -<%namespace file="utils.html" import="submit_form, plain_link"/> +<%namespace file="utils.html" import="submit_form, plain_link, timestamp"/> <%namespace file="printablebuttons.html" import="toggle_button"/>
@@ -129,7 +128,7 @@ %endif - ${_("redditor for %(time)s") % dict(time=timesince(thing.user._date))} + ${_("redditor for")} ${timestamp(thing.user)}
diff --git a/r2/r2/templates/subredditinfobar.html b/r2/r2/templates/subredditinfobar.html index ee2beba72..413f4e576 100644 --- a/r2/r2/templates/subredditinfobar.html +++ b/r2/r2/templates/subredditinfobar.html @@ -22,12 +22,11 @@ <%! import locale - from r2.lib.utils import timesince from r2.lib.strings import strings, Score from r2.lib.pages import WrappedUser %> -<%namespace file="utils.html" import="plain_link"/> +<%namespace file="utils.html" import="plain_link, timestamp"/> <%namespace file="subreddit.html" import="addremove_button" /> <%namespace file="printablebuttons.html" import="ynbutton, state_button" /> @@ -70,7 +69,7 @@ %endif - ${_("a community for %(time)s") % dict(time=timesince(thing.sr._date))} + ${_("a community for")} ${timestamp(thing.sr)} diff --git a/r2/r2/templates/utils.html b/r2/r2/templates/utils.html index ea019e1a6..e9c34ff82 100644 --- a/r2/r2/templates/utils.html +++ b/r2/r2/templates/utils.html @@ -23,7 +23,7 @@ <%! from r2.lib.filters import spaceCompress, unsafe from r2.lib.template_helpers import add_sr - from r2.lib.utils import cols + from r2.lib.utils import cols, long_datetime, timesince %> <%def name="tags(**kw)"> %for k, v in kw.iteritems(): @@ -476,6 +476,14 @@ ${unsafe(txt)} +<%def name="timestamp(thing, since=None)"> + ## todo: use pubdate attribute once things are
tags. + ## note: comment and link templates will pass a CachedVariable stub as since. + + + <%def name="percentage(slice, total)"> %if total is None or total == "" or total == 0 or slice is None or slice == "": --