Due to some missing "var"s, the script tries to set window.length
, which causes IE to throw a javascript error and prevents other javascripts on the page from running (see Template_talk:WPBS#There Seems To Be a Problem). This diff should fix it, and cleans up the rest of the missing "var"s I could spot. Anomie⚔ 17:14, 14 June 2009 (UTC)
I liked your script so much that I took the liberty of enhancing it to condense the output while still showing useful additional information. I hope you don't mind the fork. My version is at User:UncleDouggie/comments_in_local_time.js. You can also check out the diff listing. The starting point for the diff listing is your version as of 05:13, 27 July 2009 UTC with a few formatting changes to strip leading tabs from otherwise blank lines and add a small header comment. My method of invoking the script can be found here. Full documentation on the changes and the new default options is given in the script header in a format that could easily be adapted to update Wikipedia:Comments in Local Time should you desire to update your baseline.
Options used for sample timestamps:
LocalComments = { dateDifference: true, dropDays: 93, dropMonths: 24, dateFormat: 'dmy', timeFirst: true, twentyFourHours: true, // Non-default option dayOfWeek: false };
Here are some sample timestamps taken at 09:27, 30 August 2009 UTC / 02:27, 30 August 2009 (UTC-7):
The previous behavior of the script is still fully supported using these options:
LocalComments = { dateDifference: true, dropDays: 0, dropMonths: 0, dateFormat: 'dmy', timeFirst: true, twentyFourHours: false, dayOfWeek: true };
The script could easily be changed to use this last set of options as the default if desired, and it would then be fully backwards compatible. I changed the defaults since the purpose of the enhancements was obviously to change the behavior. I found the dayOfWeek=true option to be overkill. Seeing the day of the week for comments many months old didn't do much for me. The usage of "last" only for days within the last 7 days also seemed confusing. I suppose we could add another option to only show the day of the week if the date is less than 7 days old if people want it.
The number of days shown may be different from your original script in many cases because I changed the computation method. The previous method used 1 January + delta days, which was usually quite off because it mapped the second delta month to February, which has only 28 days. This resulted in somewhat strange behavior in that a date of 13 May 2009 displayed on 29 August 2009 showed a delta of (3 months, 13 days). My new method still isn't exact, but it is normally within one day, and it made adding the new features easier.
UncleDouggie (talk) 10:40, 30 August 2009 (UTC)
I just fixed a small bug and updated the diff listing link above. UncleDouggie (talk) 14:10, 30 August 2009 (UTC)
Since the release of MediaWiki 1.17, this script is frequently causing talk pages to jump on the screen when a URL is opened that includes a section anchor. I have greatly reduced this behavior in my enhanced version of the script described above. The same change could be made in the base script as well. More information is here, although that discussion will be quickly moved off into archive 85 or 86. —UncleDouggie (talk) 07:44, 21 February 2011 (UTC)
I dislike seeing the time zone, so I made a minor change and am using it now: User:Foxyshadis/comments in local time.js. Only change is inclusion of a new option, utc: false, which disables showing the time zone. (I should probably have named it tz or timeZone, meh.) Foxyshadis(talk) 05:58, 17 July 2011 (UTC)
This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
patch. Note: some new code from , otherwise it will not replaces and treat for action=edit properly.--YFdyh000 (talk) 23:28, 20 June 2016 (UTC)
@Gary: Hi! Your script is executed on page load ($(() => {
), not on wikipage.content
event. But there are scripts that update the content of the page by Ajax, without refresh by means of the browser, among which my tool Convenient Discussions. First of all, your script needs to be called like this when used together with it:
mw.hook('convenientDiscussions.commentsReady').add(function () {
importScript('User:Gary/comments in local time.js'); // ]
});
But it also doesn't work when the page is reloaded by means of the script (say, after replying). Your script is also unable to process arbitrary DOM (say, only the preview area under the comment form created by Convenient Discussions or other tool).
In Russian Wikipedia, I updated the analogous script to use the wikipage.content
event and process only the $content
passed by the event instead of the whole page content. Could you do the same? Cheers! Jack who built the house (talk) 15:24, 3 March 2021 (UTC)
@Gary: Just passing by (as I was trying to understand why your latest script changes killed one of my user scripts) and I see that you added mw-body-content
to the script. Why? — GhostInTheMachine talk to me 12:31, 24 August 2022 (UTC)