diff --git a/client/pages/panels/popup-chat.jsx b/client/pages/panels/popup-chat.jsx index ef527c7..289eb68 100644 --- a/client/pages/panels/popup-chat.jsx +++ b/client/pages/panels/popup-chat.jsx @@ -96,17 +96,23 @@ const processLine = (line, index, accessToken) => { return d.getDate() == now.getDate() && d.getMonth() == now.getMonth() && d.getFullYear() == now.getFullYear(); }; + const isThisYear = d => { + const now = new Date(Date.now()); + return d.getFullYear() == now.getFullYear(); + }; + //parse the date const date = new Date(line.createdAt); //split it up so we can format each field individually + const year = `${date.getFullYear()}`; const month = `${date.getMonth() + 1}`; const day = `${date.getDate()}`; const hours = `${date.getHours()}`; const minutes = `${date.getMinutes()}`.padStart(2, '0'); //combine into the final timestamp - const timestamp = !isValidDate(date) ? '' : isToday(date) ? `${hours}:${minutes}` : `${month}/${day}`; + const timestamp = !isValidDate(date) ? '' : isToday(date) ? `${hours}:${minutes}` : isThisYear(date) ? `${month}/${day}` : `${year}`; //generate the content string let content =
{timestamp.length > 0 ? {timestamp} : null }{line.username ? {line.username}: : ''}{line.text ? {line.text} : ''}
;