User:Mxn/CommentsInLocalTime/sandbox.js: Difference between revisions

Content deleted Content added
Overshot a bit
 
(2 intermediate revisions by the same user not shown)
Line 35:
* If a property is a function, it is called to retrieve the formatted
* timestamp string. The function must accept one argument, a `Date` object.
*
* If no `options` is specified, the timestamp adheres to the user’s date
* format and timezone preferences.
*/
outputFormats: {
Line 55 ⟶ 58:
* and <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#style_shortcuts>.
*/
// absolute: {
// dateStyle: "long",
// timeStyle: "short",
// },
},
Line 327 ⟶ 330:
// Replace the text.
//var TODO:text Replace with= formatDate(then, {type: "relative"}) once [[gerrit:1149440]] is deployed.;
var component = relativeDateComponent(then);
var text;
if (component.unit === "weeks") {
text = formatDate(then, {
type: "absolute",
options: LocalComments.outputFormats.absolute,
});
} else {
text = formatDate(then, {
type: "relative",
options: LocalComments.outputFormats.relative,
});
}
if (text) {
$(elt).text(text);
Line 346 ⟶ 336:
// Register for periodic updates.
var component = relativeDateComponent(then);
$(elt).attr("data-localcomments-unit", component.unit);
}