diff --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -71,8 +71,8 @@ from rhodecode.lib.annotate import annot from rhodecode.lib.action_parser import action_parser from rhodecode.lib.utils import repo_name_slug, get_custom_lexer from rhodecode.lib.utils2 import str2bool, safe_unicode, safe_str, \ - get_commit_safe, datetime_to_time, time_to_datetime, AttributeDict, \ - safe_int, md5, md5_safe + get_commit_safe, datetime_to_time, time_to_datetime, time_to_utcdatetime, \ + AttributeDict, safe_int, md5, md5_safe from rhodecode.lib.markup_renderer import MarkupRenderer from rhodecode.lib.vcs.exceptions import CommitDoesNotExistError from rhodecode.lib.vcs.backends.base import BaseChangeset, EmptyCommit @@ -649,13 +649,20 @@ short_id = lambda x: x[:12] hide_credentials = lambda x: ''.join(credentials_filter(x)) -def age_component(datetime_iso, value=None): +def age_component(datetime_iso, value=None, time_is_local=False): title = value or format_date(datetime_iso) - # detect if we have a timezone info, if not assume UTC + # detect if we have a timezone info, otherwise, add it if isinstance(datetime_iso, datetime) and not datetime_iso.tzinfo: tzinfo = '+00:00' + if time_is_local: + tzinfo = time.strftime("+%H:%M", + time.gmtime( + (datetime.now() - datetime.utcnow()).seconds + 1 + ) + ) + return literal( '<time class="timeago tooltip" ' 'title="{1}" datetime="{0}{2}">{1}</time>'.format( diff --git a/rhodecode/lib/utils2.py b/rhodecode/lib/utils2.py --- a/rhodecode/lib/utils2.py +++ b/rhodecode/lib/utils2.py @@ -608,6 +608,16 @@ def time_to_datetime(tm): return datetime.datetime.fromtimestamp(tm) +def time_to_utcdatetime(tm): + if tm: + if isinstance(tm, basestring): + try: + tm = float(tm) + except ValueError: + return + return datetime.datetime.utcfromtimestamp(tm) + + MENTIONS_REGEX = re.compile( # ^@ or @ without any special chars in front r'(?:^@|[^a-zA-Z0-9\-\_\.]@)' diff --git a/rhodecode/public/js/src/plugins/jquery.timeago-extension.js b/rhodecode/public/js/src/plugins/jquery.timeago-extension.js --- a/rhodecode/public/js/src/plugins/jquery.timeago-extension.js +++ b/rhodecode/public/js/src/plugins/jquery.timeago-extension.js @@ -190,7 +190,7 @@ var AgeModule = (function () { }, createTimeComponent: function(dateTime, text) { - return '<time class="timeago tooltip" title="{1}" datetime="{0}">{1}</time>'.format(dateTime, text); + return '<time class="timeago tooltip" title="{1}" datetime="{0}+0000">{1}</time>'.format(dateTime, text); } } })(); diff --git a/rhodecode/templates/admin/gists/show.html b/rhodecode/templates/admin/gists/show.html --- a/rhodecode/templates/admin/gists/show.html +++ b/rhodecode/templates/admin/gists/show.html @@ -66,7 +66,7 @@ %if c.gist.gist_expires == -1: ${_('never')} %else: - ${h.age_component(h.time_to_datetime(c.gist.gist_expires))} + ${h.age_component(h.time_to_utcdatetime(c.gist.gist_expires))} %endif </span> </div> diff --git a/rhodecode/templates/admin/my_account/my_account_auth_tokens.html b/rhodecode/templates/admin/my_account/my_account_auth_tokens.html --- a/rhodecode/templates/admin/my_account/my_account_auth_tokens.html +++ b/rhodecode/templates/admin/my_account/my_account_auth_tokens.html @@ -42,9 +42,9 @@ ${_('expires')}: ${_('never')} %else: %if auth_token.expired: - ${_('expired')}: ${h.age_component(h.time_to_datetime(auth_token.expires))} + ${_('expired')}: ${h.age_component(h.time_to_utcdatetime(auth_token.expires))} %else: - ${_('expires')}: ${h.age_component(h.time_to_datetime(auth_token.expires))} + ${_('expires')}: ${h.age_component(h.time_to_utcdatetime(auth_token.expires))} %endif %endif </td> diff --git a/rhodecode/templates/admin/users/user_edit_auth_tokens.html b/rhodecode/templates/admin/users/user_edit_auth_tokens.html --- a/rhodecode/templates/admin/users/user_edit_auth_tokens.html +++ b/rhodecode/templates/admin/users/user_edit_auth_tokens.html @@ -38,9 +38,9 @@ ${_('expires')}: ${_('never')} %else: %if auth_token.expired: - ${_('expired')}: ${h.age_component(h.time_to_datetime(auth_token.expires))} + ${_('expired')}: ${h.age_component(h.time_to_utcdatetime(auth_token.expires))} %else: - ${_('expires')}: ${h.age_component(h.time_to_datetime(auth_token.expires))} + ${_('expires')}: ${h.age_component(h.time_to_utcdatetime(auth_token.expires))} %endif %endif </td> diff --git a/rhodecode/templates/changeset/changeset_file_comment.html b/rhodecode/templates/changeset/changeset_file_comment.html --- a/rhodecode/templates/changeset/changeset_file_comment.html +++ b/rhodecode/templates/changeset/changeset_file_comment.html @@ -12,7 +12,7 @@ ${base.gravatar_with_user(comment.author.email, 16)} </div> <div class="date"> - ${h.age_component(comment.modified_at)} + ${h.age_component(comment.modified_at, time_is_local=True)} </div> <div class="status-change"> %if comment.pull_request: @@ -80,7 +80,7 @@ ${base.gravatar_with_user(comment.author.email, 16)} </div> <div class="date"> - ${h.age_component(comment.modified_at)} + ${h.age_component(comment.modified_at, time_is_local=True)} </div> %if comment.status_change: <span class="changeset-status-container"> diff --git a/rhodecode/templates/data_table/_dt_elements.html b/rhodecode/templates/data_table/_dt_elements.html --- a/rhodecode/templates/data_table/_dt_elements.html +++ b/rhodecode/templates/data_table/_dt_elements.html @@ -243,7 +243,7 @@ <%def name="gist_created(created_on)"> <div class="created"> - ${h.age_component(created_on)} + ${h.age_component(created_on, time_is_local=True)} </div> </%def> @@ -252,7 +252,7 @@ %if expires == -1: ${_('never')} %else: - ${h.age_component(h.time_to_datetime(expires))} + ${h.age_component(h.time_to_utcdatetime(expires))} %endif </div> </%def> @@ -289,7 +289,7 @@ </%def> <%def name="pullrequest_updated_on(updated_on)"> - ${h.age_component(h.time_to_datetime(updated_on))} + ${h.age_component(h.time_to_utcdatetime(updated_on))} </%def> <%def name="pullrequest_author(full_contact)"> diff --git a/rhodecode/templates/followers/followers_data.html b/rhodecode/templates/followers/followers_data.html --- a/rhodecode/templates/followers/followers_data.html +++ b/rhodecode/templates/followers/followers_data.html @@ -11,7 +11,7 @@ ${base.gravatar_with_user(f.user.email, 16)} </td> <td class="td-time follower_date"> - ${h.age_component(f.follows_from)} + ${h.age_component(f.follows_from, time_is_local=True)} </td> </tr> % endfor diff --git a/rhodecode/templates/forks/forks_data.html b/rhodecode/templates/forks/forks_data.html --- a/rhodecode/templates/forks/forks_data.html +++ b/rhodecode/templates/forks/forks_data.html @@ -22,7 +22,7 @@ <div class="truncate">${f.description}</div> </td> <td class="td-time follower_date"> - ${h.age_component(f.created_on)} + ${h.age_component(f.created_on, time_is_local=True)} </td> <td class="td-compare"> <a title="${_('Compare fork with %s' % c.repo_name)}" diff --git a/rhodecode/templates/journal/journal_data.html b/rhodecode/templates/journal/journal_data.html --- a/rhodecode/templates/journal/journal_data.html +++ b/rhodecode/templates/journal/journal_data.html @@ -28,7 +28,7 @@ </div> <div class="journal_action_params">${h.literal(h.action_parser(entry)[1]())}</div> <div class="date"> - ${h.age_component(entry.action_date)} + ${h.age_component(entry.action_date, time_is_local=True)} </div> %endfor </div> diff --git a/rhodecode/templates/search/search_commit.html b/rhodecode/templates/search/search_commit.html --- a/rhodecode/templates/search/search_commit.html +++ b/rhodecode/templates/search/search_commit.html @@ -46,7 +46,7 @@ %endif </td> <td class="td-time"> - ${h.age_component(h.time_to_datetime(entry['date']))} + ${h.age_component(h.time_to_utcdatetime(entry['date']))} </td> <td class="td-user author">