diff --git a/app/components/post_list/date_header/__snapshots__/date_header.test.js.snap b/app/components/post_list/date_header/__snapshots__/date_header.test.js.snap
index 78bd0f2f1..2fe542634 100644
--- a/app/components/post_list/date_header/__snapshots__/date_header.test.js.snap
+++ b/app/components/post_list/date_header/__snapshots__/date_header.test.js.snap
@@ -1,5 +1,65 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
+exports[`DateHeader component should match snapshot when timezone is set 1`] = `
+
+
+
+
+
+
+
+`;
+
exports[`DateHeader component should match snapshot with suffix 1`] = `
@@ -38,11 +50,7 @@ export default class DateHeader extends PureComponent {
diff --git a/app/components/post_list/date_header/date_header.test.js b/app/components/post_list/date_header/date_header.test.js
index f3b79ba4e..e60e81e55 100644
--- a/app/components/post_list/date_header/date_header.test.js
+++ b/app/components/post_list/date_header/date_header.test.js
@@ -13,6 +13,7 @@ import DateHeader from './date_header.js';
describe('DateHeader', () => {
const baseProps = {
theme: Preferences.THEMES.default,
+ timeZone: null,
};
describe('component should match snapshot', () => {
@@ -43,5 +44,20 @@ describe('DateHeader', () => {
expect(wrapper.getElement()).toMatchSnapshot();
});
+
+ it('when timezone is set', () => {
+ const props = {
+ ...baseProps,
+ dateLineString: 'date-1531152392-index-2',
+ timeZone: 'America/New_York',
+ index: 2,
+ };
+ const wrapper = shallow(
+ ,
+ {context: {intl: {formatMessage: jest.fn()}}},
+ );
+
+ expect(wrapper.getElement()).toMatchSnapshot();
+ });
});
});
diff --git a/app/components/post_list/date_header/index.js b/app/components/post_list/date_header/index.js
index 84426808c..350b28044 100644
--- a/app/components/post_list/date_header/index.js
+++ b/app/components/post_list/date_header/index.js
@@ -3,13 +3,26 @@
import {connect} from 'react-redux';
+import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
+import {getUserCurrentTimezone} from 'mattermost-redux/utils/timezone_utils';
+
+import {isTimezoneEnabled} from 'app/utils/timezone';
import DateHeader from './date_header';
function mapStateToProps(state) {
+ const enableTimezone = isTimezoneEnabled(state);
+ const currentUser = getCurrentUser(state);
+ let timeZone = null;
+
+ if (enableTimezone) {
+ timeZone = getUserCurrentTimezone(currentUser.timezone);
+ }
+
return {
theme: getTheme(state),
+ timeZone,
};
}