Skip to content

Commit

Permalink
UPT: update and add default UTC timezone TryGhost#10870
Browse files Browse the repository at this point in the history
  • Loading branch information
AlphaWong committed Oct 16, 2019
1 parent 9ca367f commit 6640fc6
Show file tree
Hide file tree
Showing 61 changed files with 183 additions and 2 deletions.
3 changes: 3 additions & 0 deletions core/frontend/apps/amp/lib/helpers/amp_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ const Promise = require('bluebird'),
urlUtils = require('../../../../../server/lib/url-utils'),
amperizeCache = {};

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

let allowedAMPTags = [],
allowedAMPAttributes = {},
amperize = null,
Expand Down
3 changes: 3 additions & 0 deletions core/frontend/helpers/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
const {SafeString, i18n} = require('./proxy');
const moment = require('moment-timezone');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

module.exports = function (date, options) {
let timezone;

Expand Down
3 changes: 3 additions & 0 deletions core/frontend/helpers/prev_next.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ var proxy = require('./proxy'),
fetch,
buildApiOptions;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

buildApiOptions = function buildApiOptions(options, post) {
var publishedAt = moment(post.published_at).format('YYYY-MM-DD HH:mm:ss'),
slug = post.slug,
Expand Down
3 changes: 3 additions & 0 deletions core/frontend/services/redirects/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const path = require('path');
const Promise = require('bluebird');
const moment = require('moment-timezone');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

const validation = require('./validation');

const config = require('../../../server/config');
Expand Down
3 changes: 3 additions & 0 deletions core/frontend/services/routing/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const fs = require('fs-extra');
const path = require('path');
const urlService = require('../url');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

const common = require('../../../server/lib/common');
const config = require('../../../server/config');

Expand Down
3 changes: 3 additions & 0 deletions core/frontend/services/sitemap/base-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const _ = require('lodash'),
urlUtils = require('../../../server/lib/url-utils'),
localUtils = require('./utils');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

// Sitemap specific xml namespace declarations that should not change
const XMLNS_DECLS = {
_attr: {
Expand Down
3 changes: 3 additions & 0 deletions core/frontend/services/sitemap/index-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ const _ = require('lodash'),
urlUtils = require('../../../server/lib/url-utils'),
localUtils = require('./utils');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

const XMLNS_DECLS = {
_attr: {
xmlns: 'http://www.sitemaps.org/schemas/sitemap/0.9'
Expand Down
3 changes: 3 additions & 0 deletions core/server/adapters/scheduling/SchedulingDefault.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const SchedulingBase = require('./SchedulingBase');
const common = require('../../lib/common');
const request = require('../../lib/request');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

/**
* @description Default post scheduling implementation.
*
Expand Down
3 changes: 3 additions & 0 deletions core/server/adapters/scheduling/post-scheduling/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const Promise = require('bluebird'),
urlUtils = require('../../../lib/url-utils'),
_private = {};

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

/**
* @description Normalize model data into scheduler notation.
* @param {Object} options
Expand Down
3 changes: 3 additions & 0 deletions core/server/adapters/storage/LocalFileStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const serveStatic = require('express').static,
urlUtils = require('../../lib/url-utils'),
StorageBase = require('ghost-storage-base');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

class LocalFileStore extends StorageBase {
constructor() {
super();
Expand Down
3 changes: 3 additions & 0 deletions core/server/api/canary/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const api = require('./index');
const internalContext = {context: {internal: true}};
const _private = {};

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

_private.fetchAllNotifications = () => {
let allNotifications = settingsCache.get('notifications');

Expand Down
3 changes: 3 additions & 0 deletions core/server/api/canary/schedules.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const urlUtils = require('../../lib/url-utils');
const common = require('../../lib/common');
const api = require('./index');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

module.exports = {
docName: 'schedules',
publish: {
Expand Down
3 changes: 3 additions & 0 deletions core/server/api/canary/utils/serializers/output/utils/date.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const moment = require('moment-timezone');
const settingsCache = require('../../../../../../services/settings/cache');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

const format = (date) => {
return moment(date)
.tz(settingsCache.get('active_timezone'))
Expand Down
3 changes: 3 additions & 0 deletions core/server/api/v0.1/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ const Promise = require('bluebird'),
internalContext = {context: {internal: true}},
canThis = permissions.canThis;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

let notifications,
_private = {};

Expand Down
3 changes: 3 additions & 0 deletions core/server/api/v0.1/schedules.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const Promise = require('bluebird'),
common = require('../../lib/common'),
postsAPI = require('./posts');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

/**
* Publish a scheduled post
*
Expand Down
3 changes: 3 additions & 0 deletions core/server/api/v2/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const api = require('./index');
const internalContext = {context: {internal: true}};
const _private = {};

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

_private.fetchAllNotifications = () => {
let allNotifications = settingsCache.get('notifications');

Expand Down
3 changes: 3 additions & 0 deletions core/server/api/v2/schedules.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ const urlUtils = require('../../lib/url-utils');
const common = require('../../lib/common');
const api = require('./index');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

module.exports = {
docName: 'schedules',
publish: {
Expand Down
3 changes: 3 additions & 0 deletions core/server/api/v2/utils/serializers/output/utils/date.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
const moment = require('moment-timezone');
const settingsCache = require('../../../../../../services/settings/cache');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

const format = (date) => {
return moment(date)
.tz(settingsCache.get('active_timezone'))
Expand Down
2 changes: 1 addition & 1 deletion core/server/data/exporter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var _ = require('lodash'),
exportFileName;

exportFileName = function exportFileName(options) {
var datetime = require('moment')().format('YYYY-MM-DD-HH-mm-ss'),
var datetime = require('moment')().utc().format('YYYY-MM-DD-HH-mm-ss'),
title = '';

options = options || {};
Expand Down
3 changes: 3 additions & 0 deletions core/server/data/importer/handlers/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var _ = require('lodash'),
processMarkdownFile,
MarkdownHandler;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

// Takes a date from the filename in y-m-d-h-m form, and converts it into a Date ready to import
processDateTime = function (post, datetime) {
var format = 'YYYY-MM-DD-HH-mm';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ const moment = require('moment');
const fs = require('fs-extra');
const path = require('path');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

module.exports.config = {
transaction: true
};
Expand Down
3 changes: 3 additions & 0 deletions core/server/data/schema/fixtures/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ var _ = require('lodash'),
findModelFixtures,
findPermissionRelationsForObject;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

/**
* ### Match Func
* Figures out how to match across various combinations of keys and values.
Expand Down
3 changes: 3 additions & 0 deletions core/server/data/validation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ var schema = require('../schema').tables,
validateSettings,
validate;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

function assertString(input) {
assert(typeof input === 'string', 'Validator js validates strings only');
}
Expand Down
3 changes: 3 additions & 0 deletions core/server/ghost-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ var debug = require('ghost-ignition').debug('server'),
common = require('./lib/common'),
moment = require('moment');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

/**
* ## GhostServer
* @constructor
Expand Down
3 changes: 3 additions & 0 deletions core/server/models/base/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const _ = require('lodash'),
validation = require('../../data/validation'),
plugins = require('../plugins');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

let ghostBookshelf,
proto;

Expand Down
3 changes: 3 additions & 0 deletions core/server/models/base/listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ var moment = require('moment-timezone'),
common = require('../../lib/common'),
sequence = require('../../lib/promise/sequence');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

/**
* @TODO REMOVE WHEN v0.1 IS DROPPED
* WHEN access token is created we will update last_seen for user.
Expand Down
3 changes: 3 additions & 0 deletions core/server/models/plugins/collision.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ var moment = require('moment-timezone'),
_ = require('lodash'),
common = require('../../lib/common');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

module.exports = function (Bookshelf) {
var ParentModel = Bookshelf.Model,
Model;
Expand Down
3 changes: 3 additions & 0 deletions core/server/models/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ const ALL_STATUSES = ['published', 'draft', 'scheduled'];
let Post;
let Posts;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

Post = ghostBookshelf.Model.extend({

tableName: 'posts',
Expand Down
3 changes: 3 additions & 0 deletions core/server/overrides.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ process.env.BLUEBIRD_DEBUG = 0;

const moment = require('moment-timezone');

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

/**
* oembed-parser uses promise-wtf to extend the global Promise with .finally
* - require it before global Bluebird Promise override so that promise-wtf
Expand Down
3 changes: 3 additions & 0 deletions core/server/services/slack.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ var common = require('../lib/common'),
'themes'
];

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

function getSlackSettings() {
var setting = settingsCache.get('slack');
// This might one day have multiple entries, for now its always a array
Expand Down
3 changes: 3 additions & 0 deletions core/server/update-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const crypto = require('crypto'),
internal = {context: {internal: true}},
allowedCheckEnvironments = ['development', 'production'];

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

function nextCheckTimestamp() {
var now = Math.round(new Date().getTime() / 1000);
return now + (24 * 3600);
Expand Down
3 changes: 3 additions & 0 deletions core/server/web/shared/middlewares/api/spam-prevention.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ let userLoginInstance;
let userResetInstance;
let contentApiKeyInstance;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

const spamConfigKeys = ['freeRetries', 'minWait', 'maxWait', 'lifetime'];

const handleStoreError = (err) => {
Expand Down
3 changes: 3 additions & 0 deletions core/test/acceptance/old/admin/pages_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const models = require('../../../../server/models');
const ghost = testUtils.startGhost;
let request;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

describe('Pages API', function () {
let ghostServer;
let ownerCookie;
Expand Down
3 changes: 3 additions & 0 deletions core/test/acceptance/old/admin/posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const models = require('../../../../server/models');
const ghost = testUtils.startGhost;
let request;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

describe('Posts API', function () {
let ghostServer;
let ownerCookie;
Expand Down
3 changes: 3 additions & 0 deletions core/test/acceptance/old/admin/users_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const models = require('../../../../server/models');
const ghost = testUtils.startGhost;
let request;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

describe('User API', function () {
let ghostServer, inactiveUser, admin;

Expand Down
3 changes: 3 additions & 0 deletions core/test/acceptance/old/content/posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const config = require('../../../../server/config');
const ghost = testUtils.startGhost;
let request;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

describe('Posts Content API', function () {
before(function () {
return ghost()
Expand Down
3 changes: 3 additions & 0 deletions core/test/regression/api/canary/admin/posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const localUtils = require('./utils');
const ghost = testUtils.startGhost;
let request;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

describe('Posts API', function () {
let ghostServer;
let ownerCookie;
Expand Down
3 changes: 3 additions & 0 deletions core/test/regression/api/canary/admin/schedules_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const localUtils = require('./utils');

const ghost = testUtils.startGhost;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

describe('Schedules API', function () {
const resources = [];
let request;
Expand Down
3 changes: 3 additions & 0 deletions core/test/regression/api/v0.1/authentication_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ var should = require('should'),
ghost = testUtils.startGhost,
request;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

describe('Authentication API', function () {
var accesstoken = '', ghostServer;

Expand Down
3 changes: 3 additions & 0 deletions core/test/regression/api/v0.1/posts_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ var should = require('should'),
markdownToMobiledoc = testUtils.DataGenerator.markdownToMobiledoc,
request;

// fix issue https://github.com/TryGhost/Ghost/issues/10870
moment.tz.setDefault('UTC');

describe('Post API', function () {
let authorAccessToken, contributorAccessToken, author, contributor;
var ghostServer;
Expand Down
Loading

0 comments on commit 6640fc6

Please sign in to comment.