| 157 | 157 | //Does not break old characters/chats, as the code just uses whatever timestamp exists in the chat. |
| 158 | 158 | //New chats made with characters will use this new formatting. |
| 159 | 159 | export function humanizedDateTime() { |
| 160 | 160 | letconst baseDatenow = new Date(Date.now()); |
| 161 | | - let humanYear = baseDate.getFullYear(); |
| 161 | + const dt = { |
| 162 | | - let humanMonth = baseDate.getMonth() + 1; |
| 162 | + year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(), |
| 163 | | - let humanDate = baseDate.getDate(); |
| 163 | + hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(), |
| 164 | | - let humanHour = (baseDate.getHours() < 10 ? '0' : '') + baseDate.getHours(); |
| 164 | + } |
| 165 | | - let humanMinute = |
| 165 | + for (const key in dt) { |
| 166 | | - (baseDate.getMinutes() < 10 ? '0' : '') + baseDate.getMinutes(); |
| 166 | + dt[key] = dt[key].toString().padStart(2, '0'); |
| 167 | | - let humanSecond = |
| 167 | + } |
| 168 | | - (baseDate.getSeconds() < 10 ? '0' : '') + baseDate.getSeconds(); |
| 168 | + return `${dt.year}-${dt.month}-${dt.day}@${dt.hour}h${dt.minute}m${dt.second}s`; |
| 169 | | - let HumanizedDateTime = |
| 170 | | - humanYear + '-' + humanMonth + '-' + humanDate + '@' + humanHour + 'h' + humanMinute + 'm' + humanSecond + 's'; |
| 171 | | - return HumanizedDateTime; |
| 172 | 169 | } |
| 173 | 170 | |
| 174 | 171 | //this is a common format version to display a timestamp on each chat message |