Wikipedia talk:Comments in Local Time

From Wikipedia, the free encyclopedia
Jump to: navigation, search

I am a childrens rights activist[edit]

I am a childrens rights activist, and would like to add an update to the Wikipedia page titled: Family Preservation....We have a new act that was in-acted in 2007. If someone could, please update that page, and add information from the Wikipedia page...pdf Family Preservation Act of 2007. It is in pdf, and we would like it to be a regular page, so that when we post it, it will have it's own title page, and our other activists will realize what it is. This is a very important step that was taken to further our cause. Any help would be appreciated. Thank you. Miss Marion — Preceding unsigned comment added by Mariontribe (talkcontribs) 07:25, 11 August 2012 (UTC)

I'm slightly confused as to what you're trying to do. This is also not the right place to place an edit request. Why don't you try Talk:Family preservation instead? • Jesse V.(talk) 14:55, 29 August 2012 (UTC)

Broken outside of Monobook and Vector[edit]

I use the Modern skin and just went through and tested a bunch of others - basically none of them work except Vector, Monobook, and Chick(?). I don't know usage stats so I'm not asking to have universal support built in, but I'd love to get this working on modern. Any clues on where the issue might be? ~ Amory (utc) 06:10, 17 March 2013 (UTC)

Okay it should be working in all skins now. I didn't know that most skins don't use the bodyContent ID. Only Vector and Monobook do, apparently; however, probably 90% of users use one of those two skins, so this was never brought up with any of my scripts until now. Gary King (talk · scripts) 23:51, 17 March 2013 (UTC)
You're fantastic. ~ Amory (utc) 23:54, 17 March 2013 (UTC)

Nasty bug on Commons (source of file page disappears)[edit]

Hi Gary, I found a very nasty bug which seems to be causes by "Comments in Local Time". When I look at the source of Commons:File:Cscr-featured.svg, the whole text just disappears! I'm using Vector skin and Firefox 20.0.1 on Windows 7 x64. You can find my custom JS at Commons:User:Patrick87/vector.js. I hope there's something you can do about it, since it is very handy. --Patrick87 (talk) 21:17, 6 May 2013 (UTC)

Yeah that's a nasty bug. I'll see what I can do. This is caused by a recent edit in determining which part of a page to process, for different skins (which was addressed in the previous section). Gary King (talk · scripts) 00:50, 7 May 2013 (UTC)
Okay problem should be fixed now. Let me know if it isn't. You might need to WP:BYPASS first to make it work. Also, let me know if for some reason this script doesn't work on pages where it used to, because I might have been a bit overaggressive this time in fixing it. Gary King (talk · scripts) 01:14, 7 May 2013 (UTC)
Wow, thanks for this incredibly fast bugfix! First tests look promising, I'll get back to you if I find any issues. --Patrick87 (talk) 01:43, 7 May 2013 (UTC)

Settings not working when defined in a global JavaScript[edit]

Hi Gary,

I noticed something very strange when defining settings of "Comments in Local Time" in a global JavaScript file loaded via mw.loader.load() (see my common.js and the global.js on German Wikipedia).

The script itself is loaded reliably. The settings (defined in the same file, directly below the code to load the script) however are ignored from time to time. On a fresh page load (shift + reload in Firefox) the settings work correctly. On subsequent normal page reloads the settings work sporadically (but not always). Do you have an idea whats going wrong here?

Even stranger: It seems to always work on Commons, were I use the same global JavaScript.

Regards, --Patrick87 (talk) 14:47, 10 May 2013 (UTC)

That's very strange, but I can't promise that I can debug this. This is such a rare case, and I am not familiar with the method that you are using, nor am I familiar with the "mw.loader.load" which is relatively new. I'll check it out but I might not ever be able to figure it out, especially if it's as inconsistent as you claim.
A few quick things you could try, is #1: Move the LocalComments = {} settings to before the script; #2: Move the settings to its own file and then use importScript() on that file, again placing the importScript() line before the script itself so that the settings are loaded first. Gary King (talk · scripts) 03:16, 13 May 2013 (UTC)
Just tried #1 but it seems it didn't change anything. --Patrick87 (talk) 10:04, 13 May 2013 (UTC)

Oh, well, I actually found the problem: I additionally had the gadget version of "Comments in Local Time" activated in my preferences. Therefore it was always loaded twice on English Wikipedia (once the gadget and once from my common.js). This perfectly explains why the problem occurred only sporadically since it actually was a timing issue (depending on which script had been loaded first). --Patrick87 (talk) 04:09, 18 May 2013 (UTC)

Comments in local time localization[edit]


I just wanted to let you know that the localization instructions in the comments in local time script are incomplete.

The gadget has been present on hindi wikipedia for quite a while now in a non-working condition. I got around today to fixing it. I was able to get it working on hindi wikipedia, but there are some issues which may crop up at other wikis.

Issues I was able to fix: (complete diff)
  1. The function replaceText uses a regex to find the signatures in a page. That regex will change depending on the language/script since the monthnames in the timestamps are localized by mediawiki. (Created regex for hindi, but the regex should be moved to the language object)
  2. The function convertMonthToNumber uses the javascript date object to convert the month. But javascript doesn't accept localized monthnames.
Remaining issues:
  1. The localization part at the top needs to specify that the monthnames should be spelled exactly as they are spelled by the mediawiki timestamp. In some languages (such as hindi), the monthname can have alternate spellings. Could the script could use mw.language.months (per mw:MediaWiki_1.22/wmf15 )?
  2. The script doesn't take into account the fact that the mediawiki timestamp may be using different numerals than the standard ones. This is the case on the hindi wiktionary, for example. Fixing this needs changes to the regex as well as changes to functions to handle the numerals before passing them to the javascript date object. Further the zero padding of the date hardcodes the character 0. This would need to be changed along with handling outputting the numerals.
  3. am/pm could possibly be translated for different languages and should be moved to the language object.

Thanks for the wonderful script. I've loved it for years now. And I hope these comments are helpful. Best regards.--Siddhartha Ghai (talk) 02:20, 10 January 2014 (UTC)

Thanks for these. I've been very busy lately (as can be seen in my lack of Wikipedia contributions) but I'll try and get to these when I have time, and perhaps fix any other lingering bugs in the meantime. Gary King (talk · scripts) 03:58, 10 January 2014 (UTC)

Handling of misspelled month names[edit]

Resolved: Should be fixed now. Any dates that are in the proper format but cannot be converted to a script-readable date will just return the text with no changes made. Gary King (talk · scripts) 17:52, 29 January 2014 (UTC)

The first entry in WP:Last topic pool#Law has a month name misspelled (intentionally?) as "Fibruary." This causes the script to display something with a bunch of NaNs in it, in my case NaN:NaN, NaN undefined NaN, undefined ( from now) (UTC−NaN). My configuration is:

LocalComments = {
        dateDifference: true,
        dateFormat: 'dmy',
        timeFirst: true,
        twentyFourHours: true,
        dayOfWeek: true,
        dropDays: 122,
        dropMonths: 36

I'm not requesting the script to intelligently correct spelling (true typos should be rare because hand-typing should be rare in comparison to signature markup). I'd just like the script to generate a more informative error message, or failing that, not recognize the text as a timestamp at all when it doesn't recognize the month name. --SoledadKabocha (talk) 04:27, 25 January 2014 (UTC)

  • It appears to be an intentional misspelling. I'll see if I can't figure out how to make the script ignore timestamps or parts there-of that it doesn't recognize. Technical 13 (talk) 13:33, 25 January 2014 (UTC)
Okay this bug should be fixed now. Gary King (talk · scripts) 17:52, 29 January 2014 (UTC)

Leading zero requirement[edit]

Resolved: Fixed the bug Gary King (talk · scripts) 17:21, 29 January 2014 (UTC)

Sorry to bother you again - on Wikipedia:Requests for arbitration/Scientology, there are two timestamps at the top on 1 June 2012 which aren't being recognized due to the lack of a leading zero in front of the time.

Again, this is suggestive of manual editing/copypasting, and it is admittedly a rare case. I am fine with a "wontfix + document" resolution for this one, more so than with the above issue, but I'd just like to know whether you think it's worth doing anything. --SoledadKabocha (talk) 17:40, 28 January 2014 (UTC)

That was an easy fix so I took care of that. Gary King (talk · scripts) 17:21, 29 January 2014 (UTC)

Mixed mdy / dmy on page[edit]

Gary, is there any way to make the script convert all timestamps on pages with mdy and dmy formats mixed? I seem to remember it used to do this, but it doesn't seem to anymore. For example:

  • 09:06, 17 September 2017 (UTC)
  • 09:06, September 17, 2017 (UTC)

For me, only the top one is working, yet I've seen both show up as timestamps on the same talk page (I'm guessing that some people are forcing their format in their signatures). Thanks. Technical 13 (talk) 18:08, 29 January 2014 (UTC)

Yeah it's possible to do this but it may slow down the page loading time. The slowdown shouldn't be too much, but the question is, how often does this type of timestamp occur? Can you show me a real-world example? At the moment, the script just doesn't parse those timestamps, which for now seems fine, unless that format becomes more prevalent for some reason. And, I don't recall the script ever doing this, but I could be wrong. It can be easily checked by going through the script's history. Gary King (talk · scripts) 18:57, 29 January 2014 (UTC)
Gary, I mostly notice it on history pages, and I often copy and paste stuff from history pages into talk pages or logs
  • (cur | prev) 13:58, January 29, 2014‎ Gary King (talk | contribs)‎ . . (14,272 bytes) (+134)‎ . . (→‎Mixed mdy / dmy on page: commenting) (undo | thank)
  • (cur | prev) 13:57, January 29, 2014‎ Gary King (talk | contribs)‎ . . (14,138 bytes) (+664)‎ . . (→‎Mixed mdy / dmy on page: commenting) (undo | thank)
  • (cur | prev) 13:08, January 29, 2014‎ Technical 13 (talk | contribs)‎ . . (13,474 bytes) (+582)‎ . . (→‎Mixed mdy / dmy on page: New section.) (undo)
  • (cur | prev) 12:52, January 29, 2014‎ Gary King (talk | contribs)‎ . . (12,892 bytes) (+811)‎ . . (→‎Handling of misspelled month names: commenting) (undo | thank)
  • (cur | prev) 12:31, January 29, 2014‎ Gary King (talk | contribs)‎ . . (12,081 bytes) (+2,756)‎ . . (→‎Handling of misspelled month names: moved from my own talk page) (undo | thank)
  • (cur | prev) 12:21, January 29, 2014‎ Gary King (talk | contribs)‎ . . (9,325 bytes) (+676)‎ . . (→‎Leading zero requirement: commenting) (undo | thank)
  • ...
for example... Since I have to manually create many of my User:Technical 13/Logs, it would be great if the script could do both so I can just copy and paste in... (ARV, RFPP, warn logs (and one more I can't remember) are all manually created by C&P from the page history... Technical 13 (talk) 19:12, 29 January 2014 (UTC)
Well, I'll think about it. It wouldn't be a commonly used feature, and it'd require changing the script so that the order of the elements is taken into account. Gary King (talk · scripts) 21:42, 29 January 2014 (UTC)
I don't mind having extra code on my end (perhaps a variable or array that has it run twice, once for each method). Technical 13 (talk) 21:51, 29 January 2014 (UTC)

how it works[edit]

I can't understood this... My time is not display properly please help me....NehalDaveND (talk) 02:14, 7 March 2014 (UTC)


@Gary: For some reason timestamps are displayed with the default settings of AM/PM times, day of week and date difference despite my custom settings for Local Comments (now commented out entirely). This happened occasionally before, but since today it happens with every talk page I visit (FF31/Win7, IE11/Win7 and IE11/WinRT). I would assume it is related to your changes to the script yesterday. SiBr4 (talk) 18:08, 10 August 2014 (UTC)

Thanks I'll take a look. Shouldn't be a major problem to fix. I just rely on people to notify me when bugs occur. Gary (talk · scripts) 19:31, 10 August 2014 (UTC)
Should be fixed now. Gary (talk · scripts) 20:05, 10 August 2014 (UTC)
Also, I recommend moving your settings to above the script, so that it ensures they load first. That may help, if you say it happens intermittently before. Gary (talk · scripts) 20:23, 10 August 2014 (UTC)
Thanks, it works again. SiBr4 (talk) 20:35, 10 August 2014 (UTC)

Missing time differential[edit]

Gary King: Perhaps you can help me; I've noticed a few days ago I didn't see the "4 days ago", "Today", "3 months ago" mentions when looking at talk page messages anymore. I didn't change anything on my end. Do you know why, and how to resolve this? Thanks in advance. ☺ · Salvidrim! ·  06:43, 14 August 2014 (UTC)

So basically the script is not working for you and you just see the normal Wikipedia timestamps? I did indeed change the code recently, but the script is working for me. The person above also pointed out a bug, and so it seems like it works for them too. Are you using the script as a gadget?
What browser are you using? The best way to detect the problem is to open your browser's JavaScript Console to spot any errors. Also, a screenshot of timestamps would help, if they are not the expected timestamps.
I also just tested my test account using the Vector (default) skin, and enabled the gadget, and it worked immediately. One possibility is that the script could be interfering with one of your other ones, but that would be surprising because my changes were in fact to further protect the script from conflicting with any others. But if you want, you can try temporarily deleting all your scripts from your vector.js page, then seeing if that fixes it. Then add the scripts back one by one until it breaks, then you know which script is the problem. Gary (talk · scripts) 18:40, 14 August 2014 (UTC)
I am using it as a Gadget, with Chrome (latest), on Win7 x64. I have looked at my JavaScript consoles and removed scripts which were giving errors and I wasn't using (2 scripts), and now the timestamps work perfectly. Thanks for the help! ☺ · Salvidrim! ·  05:19, 18 August 2014 (UTC)
Excellent glad that worked out. Those scripts might have had errors, which prevented other scripts from running. Gary (talk · scripts) 17:39, 21 August 2014 (UTC)

Skip <nowiki>[edit]

Perhaps it should be considered whether <nowiki> (and/or others, <code>?) should be skipped for processing. I just hacked a workaround into a documentation page that I feel could be done better. —WOFall (talk) 19:33, 7 October 2014 (UTC)

I'll look into it. <nowiki> is an interesting one because I don't think the output HTML will indicate that NOWIKI tags are being used, at least not in a way that the timestamp would "understand" it. While for CODE and PRE tags, they are wrapped in actual HTML tags, so that could be feasible.
My primary concern is how much slower the script would get if it has to check for these tags when it runs on EVERY node. Technically, it's already a very slow script.
A FEW MINUTES after typing the above text, I wrote the code. Test it on my sandbox. It slows down the script by about 10% to 20% but it shouldn't really be noticeable; on WP:ANI the script takes 0.15 seconds with the new code.
Please report bugs if you find any, etc., thanks! Gary (talk · scripts) 21:34, 12 October 2014 (UTC)
Thanks. I hadn't considered performance, but I agree the impact doesn't sound noticeable. I'll also take this opportunity to say thank you for the ever-useful script! —WOFall (talk) 22:00, 13 October 2014 (UTC)

Time Zones[edit]

Can I use this gadget to hide the time-zone displayed in parens at the end of the timestamp? e.g. by passing a custom date regex? — Jm3 (talk) 02:23, 7 September 2015 (UTC)

Nope that feature isn't available, I've never been asked that before. Honestly the less customization available, generally, the better, as although this is impossible to check, I'd imagine that less than 1% of all users of this script actually customize it. So it's just less code to maintain. If the customization was in a GUI, for instance, then they'd be used more. But that'd just be making things way more complicated than necessary. Gary (talk · scripts) 04:22, 9 September 2015 (UTC)

Smart relative dates, aka "Difference of time in words"[edit]

Rails provides a Date formatting function called `distance_of_time_in_words` (click for source) that displays recent dates as relativized date differences. Using this date formatter, a user will see an edit or post timestamped "5 minutes ago" rather than "6:25 PM", for example. Past a certain global threshold (e.g. one year ago), dates are displayed in full localized format. As GitHub, Facebook, Twitter, and most other popular websites render dates in this way (to save users from doing mental date arithmatic), it would be nice if this gadget (if not underlying Wikipedia itself) could render dates using a similar easy to read logic.

Gary, would you be open to patches to add that functionality here? Or would that belong in a different gadget? — Jm3 (talk) 02:24, 7 September 2015 (UTC)

Would be perhaps nice to have that, but I'd generally feel like it would needlessly complicate things. Most importantly, the goal of this script was to make the new timestamp as similar to the old one as possible, because most people want the "relative date" feature, but they don't want much else to change.
Although I'm not sure exactly what you want to change, because the script already has relative dates. It doesn't have relative time, but that's about it, so I'm guessing that's the issue here? Relative times would be interesting, but on most of the big sites, I'm guessing that "1 minute ago" changes to "2 minutes ago", etc., and doing that on a large page might be intensive/annoying (and not doing it would eventually have incorrect times, if the user is scrolling a large page and doesn't refresh for minutes or even hours). Gary (talk · scripts) 04:26, 9 September 2015 (UTC)
Hi Gary, yup, the relative dates/times I'm referring to are relative to the current time; for example, "3 hours ago" is a relative timestamp. I'm conflating date and time because most languages do that with timestamps, e.g. mysql DATETIME, etc. The example in the docs labeled relative ("Today, 1:00 pm") is not really relative to anything; I think many engineers might call that format "localized / abbreviated" or something similar, rather than relative. Maybe that format is useful or expected by some experienced Wikipedian editors, but it's not what I'm referring to here. Relative timestamps, like users are used to seeing on the web, are beneficial because they take less cognitive work to parse. To compare: for a reader to parse "Today, 11:00 am", I need to know first, 1. what time it is now, then 2. mentally subtract how many hours ago 1:00pm was, 3. modulo 12 (if I'm not in a time zone which uses 24 hour time).
With a relative timestamp ("2 hours ago"), I skip all three steps — this post was 2 hours ago, regardless of what time it is now, what time zone I'm in, and whether I count 12 or 24 hour days. You raise a concern that you feel it might be annoying in certain circumstances on certain pages but I think one of the biggest benefits of taking an existing approach like relative timestamps that's already been proven to work well for a variety of highly active web communities with higher read/write editorship than Wikipedia e.g. Facebook, Twitter, and GitHub, to name three, is that we don't need to do a lot of user research. It's already the best practice. So rather than do something unintuitive that requires mental work by the user, whenever possible I'd love to make the experience simple and clear, in a way that's consistent with users expectations on the rest of the web. Jm3 (talk) 05:10, 29 September 2015 (UTC)

Rewrite using jQuery, NodeIterator, moment.js[edit]

I rewrote this gadget on the Vietnamese wikis using a combination of jQuery, NodeIterator, and moment.js (which is provided by MediaWiki core as a module). The resulting code is much more compact, accounts for Daylight Savings Time on a case-by-case basis, and supports some 82 locales thanks to moment.js.

The rewritten gadget requires Internet Explorer 9+ or any other browser, which should be fine as Wikipedia is about to drop JavaScript support for Internet Explorer 8. It performs well for me in Firefox 45 on a fairly powerful Mac. Nevertheless, I'd appreciate any testing help you can give. You can try it out at the Vietnamese Wikipedia's reference desk (English). Or you can try it out anywhere on this wiki using User:Mxn/CommentsInLocalTime.js:


 – Minh Nguyễn 💬 14:38, 1 January 2016 (UTC)

@Jm3: I wound up implementing your suggestion in User:Mxn/CommentsInLocalTime.js. – Minh Nguyễn 💬 01:50, 2 January 2016 (UTC)

Here's the full documentation: User:Mxn/CommentsInLocalTime. I found that I couldn't keep compatibility with the existing gadget's options, because none of them really fit in with the options Moment.js exposes. – Minh Nguyễn 💬 07:00, 2 January 2016 (UTC)

Not working ?[edit]

Hi, Is the script still working ? ... It's just it's no longer updating the timestamp for me (I posted this comment at 12 however it's still saying 11pm, Thanks, –Davey2010Talk 00:58, 2 June 2016 (UTC)

The script is still working. No code has changed, at least in the script. The timestamp looks correct for me there. Perhaps your area just experienced daylight savings time or something that would cause a shift in time? Or your computer's clock was changed, since it pulls the time from there. Gary (talk · scripts) 05:36, 5 June 2016 (UTC)


When I use this gadget here, some signatures are very spaces out, like the words are very seperate. 1989 (talk) 23:06, 23 December 2016 (UTC)

Please show me a screenshot. Gary (talk · scripts) 21:13, 24 December 2016 (UTC)
My apologies for responding so late. I finally figured out the problem. I assumed it was this script because it didn't do the spacing on the other project I used it for. It was actually the justify paragraphs gadget that caused it. -- MCMLXXXIX 13:22, 6 February 2017 (UTC)