Store message date in addMessage

This commit is contained in:
Simon Ser 2020-06-24 17:16:49 +02:00
parent cbe76ab824
commit 9223953e3a
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
2 changed files with 13 additions and 6 deletions

View file

@ -101,7 +101,18 @@ export default class App extends Component {
if (!msg.tags) {
msg.tags = {};
}
// TODO: set time tag if missing
if (!msg.tags["time"]) {
// Format the current time according to ISO 8601
var date = new Date();
var YYYY = date.getUTCFullYear().toString().padStart(4, "0");
var MM = (date.getUTCMonth() + 1).toString().padStart(2, "0");
var DD = date.getUTCDate().toString().padStart(2, "0");
var hh = date.getUTCHours().toString().padStart(2, "0");
var mm = date.getUTCMinutes().toString().padStart(2, "0");
var ss = date.getUTCSeconds().toString().padStart(2, "0");
var sss = date.getUTCMilliseconds().toString().padStart(3, "0");
msg.tags["time"] = `${YYYY}-${MM}-${DD}T${hh}:${mm}:${ss}.${sss}Z`;
}
var unread = Unread.NONE;
if (msg.command == "PRIVMSG" || msg.command == "NOTICE") {

View file

@ -24,11 +24,7 @@ function Nick(props) {
function LogLine(props) {
var msg = props.message;
var date = new Date();
if (msg.tags["time"]) {
date = new Date(msg.tags["time"]);
}
var date = new Date(msg.tags["time"]);
var timestamp = date.toLocaleTimeString(undefined, {
timeStyle: "short",
hour12: false,