0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

🐛 Fixed publish date in emails not respecting site's configured timezone

closes https://github.com/TryGhost/Ghost/issues/11659

- default `moment()` timezone is UTC and we store the `published_at` value in UTC
- fetch the configured timezone and convert the date into that timezone before formatting for inclusion in the email template
This commit is contained in:
Kevin Ansfield 2020-04-24 00:40:08 +01:00 committed by Daniel Lockyer
parent c385fc1aad
commit cd04262889

View file

@ -97,7 +97,10 @@ const _parseReplacements = (emailTmpl) => {
const serialize = async (postModel, options = {isBrowserPreview: false}) => {
const post = await serializePostModel(postModel);
post.published_at = post.published_at ? moment(post.published_at).format('DD MMM YYYY') : moment().format('DD MMM YYYY');
const timezone = settingsCache.get('active_timezone');
const momentDate = post.published_at ? moment(post.published_at) : moment();
post.published_at = momentDate.tz(timezone).format('DD MMM YYYY');
post.authors = post.authors && post.authors.map(author => author.name).join(',');
if (post.posts_meta) {
post.email_subject = post.posts_meta.email_subject;