| 157 | //Does not break old characters/chats, as the code just uses whatever timestamp exists in the chat. | 157 | //Does not break old characters/chats, as the code just uses whatever timestamp exists in the chat. |
| 158 | //New chats made with characters will use this new formatting. | 158 | //New chats made with characters will use this new formatting. |
| 159 | export function humanizedDateTime() { | 159 | export function humanizedDateTime() { |
| 160 | let baseDate = new Date(Date.now()); | 160 | const now = 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 | //this is a common format version to display a timestamp on each chat message | 171 | //this is a common format version to display a timestamp on each chat message |