mirror of
https://git.sr.ht/~emersion/gamja
synced 2024-11-14 19:25:26 -05:00
Store message date in addMessage
This commit is contained in:
parent
cbe76ab824
commit
9223953e3a
2 changed files with 13 additions and 6 deletions
|
@ -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") {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue