User:Bosco/Unsigned helper.js: Difference between revisions

From Test Wiki
Content deleted Content added
code formatting
makeUnsignedTemplate: refactor
Line 2: Line 2:
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],


makeUnsignedTemplate: function (user, ts, template) {
makeUnsignedTemplate: function (user, timestamp, template) {
ts = new Date(ts);
const ts = new Date(timestamp);
var h = ts.getUTCHours();
let h = ts.getUTCHours();
if (h < 10)
if (h < 10)
h = '0' + h;
h = '0' + h;
var m = ts.getUTCMinutes();
let m = ts.getUTCMinutes();
if (m < 10)
if (m < 10)
m = '0' + m;
m = '0' + m;
ts = h + ':' + m + ', ' + ts.getUTCDate() + ' ' + UnsignedHelper.months[ts.getUTCMonth()] + ' ' + ts.getUTCFullYear() + ' (UTC)';
const formattedTimestamp = `${h}:${m}, ${ts.getUTCDate()} ${UnsignedHelper.months[ts.getUTCMonth()]} ${ts.getUTCFullYear()} (UTC)`;
return '\x7b\x7bsubst:' + template + '|' + user + '|' + ts + '\x7d\x7d';
return '\x7b\x7bsubst:' + template + '|' + user + '|' + formattedTimestamp + '\x7d\x7d';
},
},