humanizedDateTime zero-pads month & day
This commit is contained in:
parent
83f458fe49
commit
b40012973e
|
@ -157,18 +157,15 @@ export function shouldSendOnEnter() {
|
||||||
//Does not break old characters/chats, as the code just uses whatever timestamp exists in the chat.
|
//Does not break old characters/chats, as the code just uses whatever timestamp exists in the chat.
|
||||||
//New chats made with characters will use this new formatting.
|
//New chats made with characters will use this new formatting.
|
||||||
export function humanizedDateTime() {
|
export function humanizedDateTime() {
|
||||||
let baseDate = new Date(Date.now());
|
const now = new Date(Date.now());
|
||||||
let humanYear = baseDate.getFullYear();
|
const dt = {
|
||||||
let humanMonth = baseDate.getMonth() + 1;
|
year: now.getFullYear(), month: now.getMonth() + 1, day: now.getDate(),
|
||||||
let humanDate = baseDate.getDate();
|
hour: now.getHours(), minute: now.getMinutes(), second: now.getSeconds(),
|
||||||
let humanHour = (baseDate.getHours() < 10 ? '0' : '') + baseDate.getHours();
|
}
|
||||||
let humanMinute =
|
for (const key in dt) {
|
||||||
(baseDate.getMinutes() < 10 ? '0' : '') + baseDate.getMinutes();
|
dt[key] = dt[key].toString().padStart(2, '0');
|
||||||
let humanSecond =
|
}
|
||||||
(baseDate.getSeconds() < 10 ? '0' : '') + baseDate.getSeconds();
|
return `${dt.year}-${dt.month}-${dt.day}@${dt.hour}h${dt.minute}m${dt.second}s`;
|
||||||
let HumanizedDateTime =
|
|
||||||
humanYear + '-' + humanMonth + '-' + humanDate + '@' + humanHour + 'h' + humanMinute + 'm' + humanSecond + 's';
|
|
||||||
return HumanizedDateTime;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//this is a common format version to display a timestamp on each chat message
|
//this is a common format version to display a timestamp on each chat message
|
||||||
|
|
Loading…
Reference in New Issue