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.
This commit is contained in:
Tim Abbott 2020-07-15 14:10:20 -07:00 committed by Tim Abbott
parent bb12e407d2
commit a785a74fd0
2 changed files with 2 additions and 8 deletions

View File

@ -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 {

View File

@ -165,12 +165,7 @@ exports.render_date = function (time, time_above, today) {
};
// Renders the timestamp returned by the <time:> 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 + "'.";