Use single format for chat timestamps

This commit is contained in:
Cohee
2023-06-19 22:05:20 +03:00
parent 2d6ed116e6
commit fb97d95dae
2 changed files with 7 additions and 1 deletions

View File

@ -1153,7 +1153,8 @@ export function addCopyToCodeBlocks(messageElement) {
function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true } = {}) { function addOneMessage(mes, { type = "normal", insertAfter = null, scroll = true } = {}) {
var messageText = mes["mes"]; var messageText = mes["mes"];
var timestamp = mes.send_date; const momentDate = timestampToMoment(mes.send_date);
const timestamp = momentDate.isValid() ? momentDate.format('LL LT') : '';
if (mes?.extra?.display_text) { if (mes?.extra?.display_text) {
messageText = mes.extra.display_text; messageText = mes.extra.display_text;
@ -5494,6 +5495,7 @@ async function createOrEditCharacter(e) {
chat[0]["is_name"] = true; chat[0]["is_name"] = true;
chat[0]["mes"] = this_ch_mes; chat[0]["mes"] = this_ch_mes;
chat[0]["extra"] = {}; chat[0]["extra"] = {};
chat[0]["send_date"] = getMessageTimeStamp();
const alternateGreetings = characters[this_chid]?.data?.alternate_greetings; const alternateGreetings = characters[this_chid]?.data?.alternate_greetings;

View File

@ -273,6 +273,10 @@ export function isOdd(number) {
} }
export function timestampToMoment(timestamp) { export function timestampToMoment(timestamp) {
if (!timestamp) {
return moment.invalid();
}
// Unix time (legacy TAI) // Unix time (legacy TAI)
if (typeof timestamp === 'number') { if (typeof timestamp === 'number') {
return moment(timestamp); return moment(timestamp);