From c3b0219d7020dd4a1db4c7f802c6651b900c0b65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B1=AA=E7=A3=8A?= Date: Tue, 9 Jan 2018 18:44:01 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fixed=20date=20helper=20timezone?= =?UTF-8?q?=20bug=20(#9382)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit closes #9381 Fixes a bug where the date helper would ignore any timezone settings, when called with a specific date option, e. g. `published_at`. --- core/server/helpers/date.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/server/helpers/date.js b/core/server/helpers/date.js index 760716d79d..eb18d95f6e 100644 --- a/core/server/helpers/date.js +++ b/core/server/helpers/date.js @@ -13,13 +13,14 @@ module.exports = function (date, options) { if (!options && date.hasOwnProperty('hash')) { options = date; date = undefined; - timezone = options.data.blog.timezone; + } - // set to published_at by default, if it's available - // otherwise, this will print the current date - if (this.published_at) { - date = moment(this.published_at).tz(timezone).format(); - } + timezone = options.data.blog.timezone; + + // set to published_at by default, if it's available + // otherwise, this will print the current date + if (this.published_at) { + date = moment(this.published_at).tz(timezone).format(); } // ensure that context is undefined, not null, as that can cause errors