Content deleted Content added
No edit summary |
No edit summary |
||
Line 144:
"ISO 8601": "YYYY-MM-DDTHH:mm:ss", // xnY-xnm-xnd"T"xnH:xni:xns
},
/**
* Regular expression matching all the timestamps inserted by this MediaWiki
* installation over the years. This regular expression
* capturing groups `hours`, `minutes`, `day`, `month`, `year`, and
* `timezone`.
*
* Until 2005:
Line 165 ⟶ 156:
* 08:51, 23 November 2015 (UTC)
*/
parseRegExp: /(?<hours>\d\d):(?<minutes>\d\d), (?<day>\d\d?) (?<month>(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\w*) (?<year>\d{4}) \((?<timezone>UTC)\)/,
/**
Line 209 ⟶ 200:
var prefixNode;
while ((prefixNode = iter.nextNode())) {
var then;
var dateNode;
var result = LocalComments.parseRegExp.exec(prefixNode.data);
if (
// Split out the timestamp into a separate text node.▼
▲ // Split out the timestamp into a separate text node.
var
▲ var suffixNode = dateNode.splitText(result[0].length);
// Determine the represented time.▼
var components = result.groups;
▲ // Determine the represented time.
var monthIndex = mw.config.get("wgMonthNames").slice(1).indexOf(components.month);
var then = moment.utc(result[0], LocalComments.parseFormat);▼
if (!then.isValid()) {▼
// Many Wikipedias started out with English as the default
// localization, so fall back to English.
if (monthIndex === -1) {
monthIndex = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"].indexOf(components.month);
▲ }
if (monthIndex === -1) {
monthIndex = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"].indexOf(components.month);
}
if (monthIndex !== -1) {
then = new Date(Date.utc(components.year, components.monthIndex, components.day, components.hours, components.minutes));
▲ if (!then.isValid()) {
// Many Wikipedias started out with English as the default
// localization, so fall back to English.
}
}
}
Line 238 ⟶ 243:
timeElt.attr("datetime", then.toISOString());
}
if (dateNode) $(dateNode).wrap(timeElt);
}
}
|