Format snapshot timestamps nicely in cPanel dropdown

Shows "Mar 5, 2026 at 17:15:16" instead of raw "2026-03-05T171516".

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-05 19:40:12 +02:00
parent 0bd75402d1
commit 043e409930

View File

@@ -121,12 +121,22 @@ function _setSelectPlaceholder(sel, text) {
sel.appendChild(opt);
}
function _formatTimestamp(ts) {
// 2026-03-05T171516 → Mar 5, 2026 at 17:15:16
var m = ts.match(/^(\d{4})-(\d{2})-(\d{2})T(\d{2})(\d{2})(\d{2})$/);
if (!m) return ts;
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var day = parseInt(m[3], 10);
var mon = months[parseInt(m[2], 10) - 1] || m[2];
return mon + ' ' + day + ', ' + m[1] + ' at ' + m[4] + ':' + m[5] + ':' + m[6];
}
function _populateSelect(sel, values) {
while (sel.options.length) sel.remove(0);
for (var i = 0; i < values.length; i++) {
var opt = document.createElement('option');
opt.value = values[i];
opt.textContent = values[i];
opt.textContent = _formatTimestamp(values[i]);
sel.appendChild(opt);
}
}