From a785a74fd0dbd1c5a3dff24d55bef0183da08f88 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Wed, 15 Jul 2020 14:10:20 -0700 Subject: [PATCH] timerender: Fix use of page_params.timezone. The page_params.timezone feature is perhaps a misfeature, but importantly it's not what is used to display the time in the message feed (it's mainly used to show others your timezone). Given that reality, we shouldn't use it for a feature whose whole purpose is to display the time using the same timezone we use in the message feed. Fixes #15790. --- static/js/rendered_markdown.js | 3 +-- static/js/timerender.js | 7 +------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/static/js/rendered_markdown.js b/static/js/rendered_markdown.js index c2355c3996..ff5185de79 100644 --- a/static/js/rendered_markdown.js +++ b/static/js/rendered_markdown.js @@ -153,8 +153,7 @@ exports.update_elements = (content) => { const timestamp = moment(time_str); if (timestamp.isValid()) { const text = $(this).text(); - const rendered_time = timerender.render_markdown_timestamp(timestamp, - null, text); + const rendered_time = timerender.render_markdown_timestamp(timestamp, text); $(this).text(rendered_time.text); $(this).attr('title', rendered_time.title); } else { diff --git a/static/js/timerender.js b/static/js/timerender.js index 41ae31e1dd..c01b90de95 100644 --- a/static/js/timerender.js +++ b/static/js/timerender.js @@ -165,12 +165,7 @@ exports.render_date = function (time, time_above, today) { }; // Renders the timestamp returned by the markdown syntax. -exports.render_markdown_timestamp = function (time, now, text) { - now = now || moment(); - if (page_params.timezone) { - now = now.tz(page_params.timezone); - time = time.tz(page_params.timezone); - } +exports.render_markdown_timestamp = function (time, text) { const hourformat = page_params.twenty_four_hour_time ? 'HH:mm' : 'h:mm A'; const timestring = time.format('ddd, MMM D YYYY, ' + hourformat); const titlestring = "This time is in your timezone. Original text was '" + text + "'.";