From 1846a8812bb276cf7cbc523199b374b72188fb6c Mon Sep 17 00:00:00 2001 From: ChrisChrome Date: Sun, 14 Sep 2025 09:44:02 -0600 Subject: [PATCH] Testing a theory --- index.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 01df23f..8630a77 100644 --- a/index.js +++ b/index.js @@ -83,9 +83,25 @@ app.get('/time.php', (req, res) => { minute: '2-digit', second: '2-digit' }); + + /* + { + ...options, + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit' + } // Old format + */ + // Example output with space-padded single digits instead of zero-padded + const spacePad = n => n.toString().padStart(2, ' '); const parts = formatter.formatToParts(date); const get = type => parts.find(p => p.type === type).value; - const formatted = `${get('day')}${get('month')}${get('year')}${get('hour')}${get('minute')}${get('second')}`; + //const formatted = `${get('day')}${get('month')}${get('year')}${get('hour')}${get('minute')}${get('second')}`; + const singleDigit = n => ' ' + (n.startsWith('0') ? n.slice(1) : n); + const formatted = `${singleDigit(get('day'))}${singleDigit(get('month'))}${singleDigit(get('year'))}${singleDigit(get('hour'))}${singleDigit(get('minute'))}${singleDigit(get('second'))}`; const msg = fs.readFileSync(path.join(__dirname, 'msg.html'), 'utf8'); res.send(`${formatted}

${msg}`); } catch (e) {