dayjs.extend(window.dayjs_plugin_utc); dayjs.extend(window.dayjs_plugin_timezone); dayjs.extend(window.dayjs_plugin_customParseFormat); dayjs.extend(window.dayjs_plugin_isToday); dayjs.extend(window.dayjs_plugin_isTomorrow); dayjs.extend(window.dayjs_plugin_isBetween); var timeStamps = document.getElementsByClassName('chatlog__timestamp'); for(var i = 0; i < timeStamps.length; i++) { const date_1 = dayjs.tz(timeStamps[i].innerText, "DD-MM-YYYY {{TIME_FORMAT}}", "{{TIMEZONE}}").local(); const date_2 = dayjs(); if (date_1.isTomorrow()) { timeStamps[i].innerText = "Tomorrow at " + date_1.format('{{TIME_FORMAT}}') } else if (date_1.isToday()) { timeStamps[i].innerText = "Today at " + date_1.format('{{TIME_FORMAT}}') } else if (date_1.add(1, 'day').isToday()) { timeStamps[i].innerText = "Yesterday at " + date_1.format('{{TIME_FORMAT}}') } else if (date_1.isBetween(date_2, date_2.subtract(7, 'day'))) { timeStamps[i].innerText = date_1.format("dddd [at] {{TIME_FORMAT}}") } else { timeStamps[i].innerText = date_1.format("DD-MM-YYYY {{TIME_FORMAT}}") } } var shortTimeStamps = document.getElementsByClassName('chatlog__short-timestamp'); for(var i = 0; i < shortTimeStamps.length; i++) { const ts = shortTimeStamps[i].getAttribute('data-timestamp'); if (ts) { // Strip any extra spaces that python's %e might have added const cleanTs = ts.replace(/\s+/g, ' ').trim(); const date_1 = dayjs.tz(cleanTs, "dddd, D MMMM YYYY {{TIME_FORMAT}}", "{{TIMEZONE}}").local(); shortTimeStamps[i].innerText = date_1.format('{{TIME_FORMAT}}'); } }