Testing a theory
This commit is contained in:
parent
14270f73af
commit
1846a8812b
18
index.js
18
index.js
|
@ -83,9 +83,25 @@ app.get('/time.php', (req, res) => {
|
||||||
minute: '2-digit',
|
minute: '2-digit',
|
||||||
second: '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 parts = formatter.formatToParts(date);
|
||||||
const get = type => parts.find(p => p.type === type).value;
|
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');
|
const msg = fs.readFileSync(path.join(__dirname, 'msg.html'), 'utf8');
|
||||||
res.send(`${formatted}<br><br>${msg}`);
|
res.send(`${formatted}<br><br>${msg}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in a new issue