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

Content deleted Content added
Undid revision 1294539792 by Mxn (talk)
Overshot a bit
 
(3 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 componenttext = relativeDateComponentformatDate(then, {type: "relative"});
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 345 ⟶ 336:
// Register for periodic updates.
var component = relativeDateComponent(then);
$(elt).attr("data-localcomments-unit", component.unit);
}