diff --git a/src/controllers/organisms/RoomView.js b/src/controllers/organisms/RoomView.js index 1300f714..29933d4a 100644 --- a/src/controllers/organisms/RoomView.js +++ b/src/controllers/organisms/RoomView.js @@ -398,6 +398,13 @@ module.exports = { continuation = false; } } + + if (i === 1) { // n.b. 1, not 0, as the 0th event is an m.room.create and so doesn't show on the timeline + var ts1 = this.state.room.timeline[i].getTs(); + dateSeparator = ; + continuation = false; + } + if (!TileType) continue; ret.unshift(
  • diff --git a/src/skins/vector/views/atoms/MessageTimestamp.js b/src/skins/vector/views/atoms/MessageTimestamp.js index e9b7bd13..cd0c7a15 100644 --- a/src/skins/vector/views/atoms/MessageTimestamp.js +++ b/src/skins/vector/views/atoms/MessageTimestamp.js @@ -20,6 +20,9 @@ var React = require('react'); var MessageTimestampController = require('matrix-react-sdk/lib/controllers/atoms/MessageTimestamp') +var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; +var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + module.exports = React.createClass({ displayName: 'MessageTimestamp', mixins: [MessageTimestampController], @@ -30,7 +33,20 @@ module.exports = React.createClass({ function pad(n) { return (n < 10 ? '0' : '') + n; } - return pad(date.getHours()) + ':' + pad(date.getMinutes()); + + var now = new Date(); + if (date.toDateString() === now.toDateString()) { + return pad(date.getHours()) + ':' + pad(date.getMinutes()); + } + else if (now.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) { + return days[date.getDay()] + " " + pad(date.getHours()) + ':' + pad(date.getMinutes()); + } + else if (now.getFullYear() === date.getFullYear()) { + return days[date.getDay()] + ", " + months[date.getMonth()] + " " + (date.getDay()+1) + " " + pad(date.getHours()) + ':' + pad(date.getMinutes()); + } + else { + return days[date.getDay()] + ", " + months[date.getMonth()] + " " + (date.getDay()+1) + " " + date().getFullYear() + " " + pad(date.getHours()) + ':' + pad(date.getMinutes()); + } }, render: function() {