User:DreamRimmer/adminnewslettertools.js: Difference between revisions

Content deleted Content added
make it simple, fix pattern
fix
Line 556:
const rfcs = [];
const rfcEntryPattern = /'''\[\[([^\]|]+)(?:\|([^\]]+))?\]\]'''[\s\S]*?\{\{rfcquote\|text=([\s\S]*?)\}\}[\s\S]*?(\d{2}:\d{2}, \d{1,2} \w+ \d{4} \(UTC\))/g;
const now = new Date();
const currentUtcYear = now.getUTCFullYear();
const currentUtcMonth = now.getUTCMonth();
const currentUtcDate = now.getUTCDate();
const currentUtcHours = now.getUTCHours();
const currentUtcMinutes = now.getUTCMinutes();
const currentUtc = new Date(Date.UTC(currentUtcYear, currentUtcMonth, currentUtcDate, currentUtcHours, currentUtcMinutes, 0, 0));
let match;
Line 572 ⟶ 579:
let daysDiff = null;
if (timestampStr) {
const parsedDatetsMatch = new Date(timestampStr.replacematch(' /(UTC\d{2}):(\d{2})', '(\d{1,2}) (\w+) (\d{4}) \(UTC'\)/);
if (!isNaN(parsedDate)tsMatch) {
const now[_, =hour, newminute, day, monthText, year] = Date()tsMatch;
daysDiffconst months = Math.floor((now - parsedDate) / (1000 * 60 * 60 * 24));[
"January","February","March","April","May","June","July","August","September","October","November","December"
];
const monthNum = months.indexOf(monthText);
if (monthNum !== -1) {
const tsDate = new Date(Date.UTC(
parseInt(year,10),
monthNum,
parseInt(day,10),
parseInt(hour,10),
parseInt(minute,10),
0, 0
));
daysDiff = Math.floor((currentUtc - tsDate) / (1000 * 60 * 60 * 24));
}
}
}