diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-04-10 16:31:47 -0500 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2012-04-10 16:31:47 -0500 |
commit | 511a7e1d9a7b1ed2fa60c3a58e0191f975384c6d (patch) | |
tree | 0bd1d10812474b124541947301ce4827694b335a | |
parent | bfa1229693151aa454ef9c176816581a5a52d624 (diff) | |
download | askbot-511a7e1d9a7b1ed2fa60c3a58e0191f975384c6d.tar.gz askbot-511a7e1d9a7b1ed2fa60c3a58e0191f975384c6d.tar.bz2 askbot-511a7e1d9a7b1ed2fa60c3a58e0191f975384c6d.zip |
added the timezone offset to the timestamps in the html output and hopefully fixed the related "timeago" issue
-rw-r--r-- | askbot/__init__.py | 1 | ||||
-rw-r--r-- | askbot/skins/common/media/js/utils.js | 2 | ||||
-rw-r--r-- | askbot/skins/default/templates/macros.html | 4 | ||||
-rw-r--r-- | askbot/templatetags/extra_filters_jinja.py | 11 | ||||
-rw-r--r-- | askbot_requirements.txt | 1 | ||||
-rw-r--r-- | askbot_requirements_dev.txt | 1 |
6 files changed, 17 insertions, 3 deletions
diff --git a/askbot/__init__.py b/askbot/__init__.py index 7b8a7280..af9603e1 100644 --- a/askbot/__init__.py +++ b/askbot/__init__.py @@ -34,6 +34,7 @@ REQUIREMENTS = { 'openid': 'python-openid', 'pystache': 'pystache==0.3.1', 'lamson': 'Lamson', + 'pytz': 'pytz', } #necessary for interoperability of django and coffin diff --git a/askbot/skins/common/media/js/utils.js b/askbot/skins/common/media/js/utils.js index fe6bcc1a..42a7e3be 100644 --- a/askbot/skins/common/media/js/utils.js +++ b/askbot/skins/common/media/js/utils.js @@ -701,7 +701,7 @@ var AutoCompleter=function(a){var b={autocompleteMultiple:true,multipleSeparator } function distance(date) { - return (new Date().getTime() - date.getTime()); + return (new Date() - date); } // fix for IE6 suckage diff --git a/askbot/skins/default/templates/macros.html b/askbot/skins/default/templates/macros.html index d4871f44..d67cf7cd 100644 --- a/askbot/skins/default/templates/macros.html +++ b/askbot/skins/default/templates/macros.html @@ -693,7 +693,7 @@ answer {% if answer.accepted() %}accepted-answer{% endif %} {% if answer.author_ {%- endmacro -%} {%- macro timeago(datetime_object) -%} - <abbr class="timeago" title="{{datetime_object.replace(microsecond=0)}}"> - {{datetime_object.replace(microsecond=0)}} + <abbr class="timeago" title="{{datetime_object.replace(microsecond=0)|add_tz_offset}}"> + {{datetime_object.replace(microsecond=0)|add_tz_offset}} </abbr> {%- endmacro -%} diff --git a/askbot/templatetags/extra_filters_jinja.py b/askbot/templatetags/extra_filters_jinja.py index 8083657d..b03e4a89 100644 --- a/askbot/templatetags/extra_filters_jinja.py +++ b/askbot/templatetags/extra_filters_jinja.py @@ -1,4 +1,5 @@ import datetime +import pytz import re import time import urllib @@ -35,6 +36,16 @@ def absolutize_urls_func(text): return url_re4.sub(replacement, text) absolutize_urls = register.filter(absolutize_urls_func) +TIMEZONE_STR = pytz.timezone( + django_settings.TIME_ZONE + ).localize( + datetime.datetime.now() + ).strftime('%z') + +@register.filter +def add_tz_offset(datetime_object): + return str(datetime_object) + ' ' + TIMEZONE_STR + @register.filter def strip_path(url): """removes path part of the url""" diff --git a/askbot_requirements.txt b/askbot_requirements.txt index 5bf06e30..c82f17f0 100644 --- a/askbot_requirements.txt +++ b/askbot_requirements.txt @@ -18,3 +18,4 @@ django-followit django-recaptcha-works python-openid pystache==0.3.1 +pytz diff --git a/askbot_requirements_dev.txt b/askbot_requirements_dev.txt index e05e53b6..e725252c 100644 --- a/askbot_requirements_dev.txt +++ b/askbot_requirements_dev.txt @@ -19,3 +19,4 @@ django-recaptcha-works python-openid pystache==0.3.1 pylint +pytz |