humanizedDateTime zero-pads month & day

b40012973e8803c0d69632a588493198b77c440f

Succubyss <87207237+Succubyss@users.noreply.github.com>

1 files changed, +9 -12Showing whitespace changes
public/scripts/RossAscends-mods.js+9 -12
@@ -157,18 +157,15 @@ export function shouldSendOnEnter() {
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.
159export function humanizedDateTime() {159export 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}
173170
174//this is a common format version to display a timestamp on each chat message171//this is a common format version to display a timestamp on each chat message