From a22f14e9101fb91dc619d1506611aeb2c33a3019 Mon Sep 17 00:00:00 2001 From: turt2live Date: Thu, 22 Jun 2017 08:53:58 -0600 Subject: [PATCH] Use 12h timestamps when enabled in RR Fixes vector-im/riot-web#4393 Signed-off-by: Travis Ralston --- src/DateUtils.js | 6 +++--- src/components/views/rooms/EventTile.js | 1 + src/components/views/rooms/ReadReceiptMarker.js | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/DateUtils.js b/src/DateUtils.js index 0bce7c8a16..545d92dd3b 100644 --- a/src/DateUtils.js +++ b/src/DateUtils.js @@ -60,7 +60,7 @@ function twelveHourTime(date) { } module.exports = { - formatDate: function(date) { + formatDate: function(date, showTwelveHour=false) { var now = new Date(); const days = getDaysArray(); const months = getMonthsArray(); @@ -69,7 +69,7 @@ module.exports = { } else if (now.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) { // TODO: use standard date localize function provided in counterpart - return _t('%(weekDayName)s %(time)s', {weekDayName: days[date.getDay()], time: this.formatTime(date)}); + return _t('%(weekDayName)s %(time)s', {weekDayName: days[date.getDay()], time: this.formatTime(date, showTwelveHour)}); } else if (now.getFullYear() === date.getFullYear()) { // TODO: use standard date localize function provided in counterpart @@ -80,7 +80,7 @@ module.exports = { time: this.formatTime(date), }); } - return this.formatFullDate(date); + return this.formatFullDate(date, showTwelveHour); }, formatFullDate: function(date, showTwelveHour=false) { diff --git a/src/components/views/rooms/EventTile.js b/src/components/views/rooms/EventTile.js index 5c970a0966..170925999d 100644 --- a/src/components/views/rooms/EventTile.js +++ b/src/components/views/rooms/EventTile.js @@ -336,6 +336,7 @@ module.exports = WithMatrixClient(React.createClass({ suppressAnimation={this._suppressReadReceiptAnimation} onClick={this.toggleAllReadAvatars} timestamp={receipt.ts} + showTwelveHour={this.props.isTwelveHour} /> ); } diff --git a/src/components/views/rooms/ReadReceiptMarker.js b/src/components/views/rooms/ReadReceiptMarker.js index 7565b0741d..64b54fe1e1 100644 --- a/src/components/views/rooms/ReadReceiptMarker.js +++ b/src/components/views/rooms/ReadReceiptMarker.js @@ -66,6 +66,9 @@ module.exports = React.createClass({ // Timestamp when the receipt was read timestamp: React.PropTypes.number, + + // True to show twelve hour format, false otherwise + showTwelveHour: React.PropTypes.bool, }, getDefaultProps: function() { @@ -172,7 +175,7 @@ module.exports = React.createClass({ if (this.props.timestamp) { title = _t( "Seen by %(userName)s at %(dateTime)s", - {userName: this.props.member.userId, dateTime: DateUtils.formatDate(new Date(this.props.timestamp))} + {userName: this.props.member.userId, dateTime: DateUtils.formatDate(new Date(this.props.timestamp), this.props.showTwelveHour)} ); }