diff --git a/src/DateUtils.js b/src/DateUtils.js
index c58c09d4de..f787fc0e20 100644
--- a/src/DateUtils.js
+++ b/src/DateUtils.js
@@ -16,27 +16,37 @@ limitations under the License.
'use strict';
-var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
-var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+import UserSettingsStore from './UserSettingsStore';
+const days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
+let time;
function pad(n) {
return (n < 10 ? '0' : '') + n;
}
+function twentyfourhour(date) {
+ let hours = date.getHours();
+ let minutes = date.getMinutes();
+ let ampm = hours >= 12 ? 'PM' : 'AM';
+ hours = hours % 12;
+ hours = hours ? hours : 12;
+ minutes = minutes < 10 ? '0'+minutes : minutes;
+ var strTime = hours + ':' + minutes + ' ' + ampm;
+ return strTime;
+}
+
module.exports = {
formatDate: function(date) {
- // date.toLocaleTimeString is completely system dependent.
- // just go 24h for now
-
var now = new Date();
if (date.toDateString() === now.toDateString()) {
- return pad(date.getHours()) + ':' + pad(date.getMinutes());
+ return this.formatTime(date);
}
else if (now.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) {
- return days[date.getDay()] + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
+ return days[date.getDay()] + " " + this.formatTime(date);
}
else if (now.getFullYear() === date.getFullYear()) {
- return days[date.getDay()] + ", " + months[date.getMonth()] + " " + date.getDate() + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
+ return days[date.getDay()] + ", " + months[date.getMonth()] + " " + date.getDate() + " " + this.formatTime(date);
}
else {
return this.formatFullDate(date);
@@ -44,11 +54,13 @@ module.exports = {
},
formatFullDate: function(date) {
- return days[date.getDay()] + ", " + months[date.getMonth()] + " " + date.getDate() + " " + date.getFullYear() + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
+ return days[date.getDay()] + ", " + months[date.getMonth()] + " " + date.getDate() + " " + date.getFullYear() + " " + this.formatTime(date);
},
formatTime: function(date) {
+ if (UserSettingsStore.getSyncedSetting('showTwelveHourTimestamps')) {
+ return twentyfourhour(date);
+ }
return pad(date.getHours()) + ':' + pad(date.getMinutes());
- }
+ },
};
-
diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js
index 2c1f17ee3e..45774d7a6a 100644
--- a/src/components/structures/UserSettings.js
+++ b/src/components/structures/UserSettings.js
@@ -65,7 +65,6 @@ const SETTINGS_LABELS = [
id: 'dontSendTypingNotifications',
label: "Don't send typing notifications",
},
-/*
{
id: 'alwaysShowTimestamps',
label: 'Always show message timestamps',
@@ -74,6 +73,7 @@ const SETTINGS_LABELS = [
id: 'showTwelveHourTimestamps',
label: 'Show timestamps in 12 hour format (e.g. 2:30pm)',
},
+/*
{
id: 'useCompactLayout',
label: 'Use compact timeline layout',
diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js
index 44c4051995..6ec076ba95 100644
--- a/src/components/views/rooms/EventTile.js
+++ b/src/components/views/rooms/EventTile.js
@@ -16,6 +16,8 @@ limitations under the License.
'use strict';
+import UserSettingsStore from '../../../UserSettingsStore';
+
var React = require('react');
var classNames = require("classnames");
var Modal = require('../../../Modal');
@@ -479,24 +481,31 @@ module.exports = WithMatrixClient(React.createClass({
);
var e2e;
+ let e2e_style;
// cosmetic padlocks:
+ if (UserSettingsStore.getSyncedSetting('showTwelveHourTimestamps')) {
+ e2e_style = "mx_EventTile_e2eIcon mx_EventTile_e2eIcon_12hr";
+ }
+ else {
+ e2e_style = "mx_EventTile_e2eIcon";
+ }
if ((e2eEnabled && this.props.eventSendStatus) || this.props.mxEvent.getType() === 'm.room.encryption') {
- e2e =
;
+ e2e =
;
}
// real padlocks
else if (this.props.mxEvent.isEncrypted() || (e2eEnabled && this.props.eventSendStatus)) {
if (this.props.mxEvent.getContent().msgtype === 'm.bad.encrypted') {
- e2e =
;
+ e2e =
;
}
else if (this.state.verified == true || (e2eEnabled && this.props.eventSendStatus)) {
- e2e =
;
+ e2e =
;
}
else {
- e2e =
;
+ e2e =
;
}
}
else if (e2eEnabled) {
- e2e =
;
+ e2e =
;
}
const timestamp = this.props.mxEvent.getTs() ?
: null;