Wikipedia talk:Comments in Local Time/Archive 1
This is an archive of past discussions about Wikipedia:Comments in Local Time. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 |
Move the Time to before the Date?
In the script, should I move the time to before the date, just like how it looks by default in signatures? I'm bringing this up because, basically, the script should change as little as possible by default, so that users can get used to it without feeling that it has changed too much. Which is why I've changed the default font size from 90% to 100%, so that it stays the same. Gary King (talk) 20:10, 27 January 2009 (UTC)
- I think the time should be moved, yeah, but I preferred it at 90% (is there any way to get it back in the config?) Dendodge TalkContribs 20:56, 27 January 2009 (UTC)
- Read WP:LOCO#Settings. Also, I moved the time, let's see how that goes. Gary King (talk) 21:06, 27 January 2009 (UTC)
- I've decided to change the size to 95%. I think that the biggest problem with 100% is that the timestamp blends in too much with the text. The problem with 90% is that it might be too small for some people with poor eyesight, so 95% is a compromise. Gary King (talk) 21:19, 27 January 2009 (UTC)
- Personally, I much prefer the previous format, where the date comes first. It feels more intuitive, especially with older comments. Could this be configured as a preference please? --Ckatzchatspy 21:34, 27 January 2009 (UTC)
- I added it to the to do list and will get to it later today. Gary King (talk) 21:56, 27 January 2009 (UTC)
- I like it when the time comes first. It makes it much easier to follow the chronology of a thread, especially when the comments are made in quick succesion. Dabomb87 (talk) 22:19, 27 January 2009 (UTC)
- Whichever you like, the new setting is at WP:LOCO#Settings for you to choose if you want time or date first. Also Dabomb, I think that most people read recent comments rather than old ones, so yeah, time is typically more useful. Gary King (talk) 22:36, 27 January 2009 (UTC)
- I like it when the time comes first. It makes it much easier to follow the chronology of a thread, especially when the comments are made in quick succesion. Dabomb87 (talk) 22:19, 27 January 2009 (UTC)
- I added it to the to do list and will get to it later today. Gary King (talk) 21:56, 27 January 2009 (UTC)
- Personally, I much prefer the previous format, where the date comes first. It feels more intuitive, especially with older comments. Could this be configured as a preference please? --Ckatzchatspy 21:34, 27 January 2009 (UTC)
- I've decided to change the size to 95%. I think that the biggest problem with 100% is that the timestamp blends in too much with the text. The problem with 90% is that it might be too small for some people with poor eyesight, so 95% is a compromise. Gary King (talk) 21:19, 27 January 2009 (UTC)
- Read WP:LOCO#Settings. Also, I moved the time, let's see how that goes. Gary King (talk) 21:06, 27 January 2009 (UTC)
Bug
Right now, it's converting the 22:59, 31 January 2009 (UTC) timestamp into CURRENTTIME am, 32 January 2009, last Saturday (2 days ago) (UTC+WHATEVER). 32nd of January? 2 days ago? Both are incorrect. I suspect a bug. Thankyou. Foxy Loxy Pounce! 22:59, 31 January 2009 (UTC)
- What's your timezone? Could you post exactly what it appears to you, instead of using placeholders? The script used to have problems with days at the end of months; it always passes after today and yesterday are not in different months. I thought I had fixed it, but it might still be problematic in some timezones or something. Gary King (talk) 23:14, 31 January 2009 (UTC)
- Ok, the timestamp on your message above is appearing as 8:14 am, 32 January 2009, last Saturday (2 days ago) (UTC+9). Foxy Loxy Pounce! 23:36, 31 January 2009 (UTC)
- Thanks; I'm working on fixing it now. I think it was fixed in the past few months but recently, as in the past few weeks, something must have went wrong. Gary King (talk) 01:47, 1 February 2009 (UTC)
- The timestamp I quoted before shows as 8:14 am, 4 January 2009, Saturday (30 days ago) (UTC+9) (30 days and a wrong date) but the timestamp on your last response appears correctly as 10:47 am, Today (UTC+9) Foxy Loxy Pounce! 01:58, 1 February 2009 (UTC)
- Yep, I know. There's only a small window when the problem occurs, which is why sometimes I don't notice it. I'm still working on it though. Gary King (talk) 01:59, 1 February 2009 (UTC)
- Okay, problem solved. After spending a few hours debugging the script (and making a few minor fixes along the way), I discovered that the solution was amazingly simple. It just goes to show that in programming, the smallest misplaced code can have the biggest effect :) Gary King (talk) 03:26, 1 February 2009 (UTC)
- Yep, I know. There's only a small window when the problem occurs, which is why sometimes I don't notice it. I'm still working on it though. Gary King (talk) 01:59, 1 February 2009 (UTC)
- The timestamp I quoted before shows as 8:14 am, 4 January 2009, Saturday (30 days ago) (UTC+9) (30 days and a wrong date) but the timestamp on your last response appears correctly as 10:47 am, Today (UTC+9) Foxy Loxy Pounce! 01:58, 1 February 2009 (UTC)
- Thanks; I'm working on fixing it now. I think it was fixed in the past few months but recently, as in the past few weeks, something must have went wrong. Gary King (talk) 01:47, 1 February 2009 (UTC)
- Ok, the timestamp on your message above is appearing as 8:14 am, 32 January 2009, last Saturday (2 days ago) (UTC+9). Foxy Loxy Pounce! 23:36, 31 January 2009 (UTC)
YAY! Thanks for that. §hep • Talk 03:27, 1 February 2009 (UTC)
Ditto, thanks a lot. I haven't had a chance to test it yet, as I'm on my mobile (no javascript).Foxy Loxy Pounce! 04:09, 1 February 2009 (UTC)
Unsigned
A minor issue, but is it possible to make the timestamp format (into the preferred date format) from the unsigned template? Dabomb87 (talk) 16:07, 3 February 2009 (UTC)
- To do that would require ignoring the (UTC) placed at the end of timestamps. In almost all cases, timestamps are indeed in UTC format rather than UTC-5 or something, but the script might as well still take the UTC into account, just in case a timestamp is ever posted in a different timezone. Just do this. Gary King (talk) 16:14, 3 February 2009 (UTC)
- Thanks. Dabomb87 (talk) 16:20, 3 February 2009 (UTC)
Glitch
Messed up again ... I am getting "7:26 am, 10 February 2009, Tuesday (31 days from now)". Dabomb87 (talk) 13:32, 10 February 2009 (UTC)
- Where? I need the source date to be able to fix this; you can see it in edit mode.
12:26, 10 February 2009 (UTC)
is 7:26 am on that date for me, and it looks fine. Gary King (talk) 16:38, 10 February 2009 (UTC)
- What date's your internal clock set to? — Blue-Haired Lawyer 17:36, 10 February 2009 (UTC)
- "31 days from now"? By the way, I am UTC−6. I haven't set the internal clock in my preferences. Dabomb87 (talk) 22:25, 10 February 2009 (UTC)
- Where do you see this? I'm not seeing it. Gary King (talk) 23:49, 10 February 2009 (UTC)
- Seems to have fixed itself. Dabomb87 (talk) 00:39, 11 February 2009 (UTC)
- Nope, it is glitchy again. From Sabre's RfA "1:16 pm, 18 February 2009, Wednesday (1 month, 7 days from now) (UTC−6)" The "1 month" is wrong. Dabomb87 (talk) 22:19, 11 February 2009 (UTC)
- Experiencing this time as well, same page Scheduled to end 2:16 pm, February 18, 2009, this Wednesday (7 days from now) (UTC−5) I'm only off by a week though... §hep • Talk 22:25, 11 February 2009 (UTC)
- Shep, it is seven days from now. Yours is shown correctly; it appears like that for me. I can't help Dabomb without more information. Like, perhaps your computer's settings including the date and time, timezone, etc. when the problem occurred, and whatever else you think might help and might affect the script. Perhaps even take a screenshot of the issue, and upload it to somewhere like Imageshack. Gary King (talk) 04:15, 12 February 2009 (UTC)
- Experiencing this time as well, same page Scheduled to end 2:16 pm, February 18, 2009, this Wednesday (7 days from now) (UTC−5) I'm only off by a week though... §hep • Talk 22:25, 11 February 2009 (UTC)
- Nope, it is glitchy again. From Sabre's RfA "1:16 pm, 18 February 2009, Wednesday (1 month, 7 days from now) (UTC−6)" The "1 month" is wrong. Dabomb87 (talk) 22:19, 11 February 2009 (UTC)
- Seems to have fixed itself. Dabomb87 (talk) 00:39, 11 February 2009 (UTC)
- Where do you see this? I'm not seeing it. Gary King (talk) 23:49, 10 February 2009 (UTC)
- "31 days from now"? By the way, I am UTC−6. I haven't set the internal clock in my preferences. Dabomb87 (talk) 22:25, 10 February 2009 (UTC)
(outdent) OK, I will take a screenshot. Dabomb87 (talk) 04:46, 12 February 2009 (UTC)
- ...And once again, the problem has amended itself. Don't rest easy though, this seems to be a recurring incident. Next time it occurs, I will post a screenshot and give more info. Dabomb87 (talk) 04:48, 12 February 2009 (UTC)
- I assume the problem is related to what time it is for you. So, perhaps mark down the times when the problem occurs. Or perhaps someone has been drinking a little too much :p Gary King (talk) 04:49, 12 February 2009 (UTC)
- Not a drinker or smoker by choice, so I don't think that is the problem :) To the point though, I think you are right about it only happening at certain time periods. It is hard to keep track during the week, so I will have to look into it during the weekend. Dabomb87 (talk) 05:05, 12 February 2009 (UTC)
- WTF? I could have sworn that date I read was yesterday's date...and I can't drink.Legally §hep • Talk 23:42, 12 February 2009 (UTC)
- It didn't act up today, so either the glitch fixed itself or it only happens on certain days. Granted, I haven't been on Wiki much today. Dabomb87 (talk) 00:46, 13 February 2009 (UTC)
- WTF? I could have sworn that date I read was yesterday's date...and I can't drink.Legally §hep • Talk 23:42, 12 February 2009 (UTC)
- Not a drinker or smoker by choice, so I don't think that is the problem :) To the point though, I think you are right about it only happening at certain time periods. It is hard to keep track during the week, so I will have to look into it during the weekend. Dabomb87 (talk) 05:05, 12 February 2009 (UTC)
- I assume the problem is related to what time it is for you. So, perhaps mark down the times when the problem occurs. Or perhaps someone has been drinking a little too much :p Gary King (talk) 04:49, 12 February 2009 (UTC)
Is it this script?
At Wikipedia:Sockpuppet investigations/Jaredsacks I get a funny external edit link in the heading. When I remove the <big>'s or log out everything looks fine. Since it's around a timestamp I was wondering if this script might be the culprit...before I start removing my scripts one at a time until I hit the problem. Thanks, §hepTalk 08:35, 16 February 2009 (UTC)
- Yeah it's the script. I've been working on a solution, which I will implement soon. This problem only occurs when timestamps are used in headings. Gary King (talk) 20:44, 16 February 2009 (UTC)
- Okay, I think I've fixed it. I had to fundamentally rewrite the script, but it's worth it since it makes the script better and more future-proof. Here's the diff for those interested; I added in a function that walks each element on a page and replaces only the text, rather than anything inside HTML tags. Neato! Gary King (talk) 22:25, 16 February 2009 (UTC)
- Hm, close, but not quite there yet. Some dates aren't formatted, while some are. Strange. Gary King (talk) 22:28, 16 February 2009 (UTC)
- Okay, I think I've fixed it. I had to fundamentally rewrite the script, but it's worth it since it makes the script better and more future-proof. Here's the diff for those interested; I added in a function that walks each element on a page and replaces only the text, rather than anything inside HTML tags. Neato! Gary King (talk) 22:25, 16 February 2009 (UTC)
Major script update
I have updated the code, fixing a problem brought up in the above section, which means that although there should be no major bugs, there might be a few minor ones, so if you come across something, please let me know. For those who are interested, I rewrote the fundamental way in which the script searches for timestamps on pages. Before, the script looked through the entire page, including inside HTML tags, causing some problems like the one mentioned above. This happened very rarely, but fixing it also helped some other things, so I went ahead and did it. The script now searches only the text, and within each HTML tag on every page, for timestamps. In addition to making the script not breaking any HTML tags, it should also make it run a little faster. Gary King (talk) 01:53, 17 February 2009 (UTC)
February 2009 is all wrong
It's erroneously displaying everything from February 2009 as being a month later. Check out the dates above. MANdARAX • XAЯAbИAM 19:30, 30 March 2009 (UTC)
- I have noticed that too and am working on it. Gary King (talk) 19:50, 30 March 2009 (UTC)
- Okay fixed. The problem only happens when today is March 29, 30, or 31 as last February doesn't have those days. Gary King (talk) 20:28, 30 March 2009 (UTC)
- Thanks for the quick fix. MANdARAX • XAЯAbИAM 20:45, 30 March 2009 (UTC)
- Okay fixed. The problem only happens when today is March 29, 30, or 31 as last February doesn't have those days. Gary King (talk) 20:28, 30 March 2009 (UTC)
Weird format problem
See the first paragraph here, its screwing with the text for some reason. Alexfusco5 01:25, 2 April 2009 (UTC)
- I made a temporary fix for now, which only formats the first timestamp when more than two timestamps are found in the same line. Gary King (talk) 16:21, 2 April 2009 (UTC)
Want to turn off the "xxx days ago" feature
Can this bit be turned off? –xeno (talk) 13:10, 2 April 2009 (UTC)
- Okay, there's a new setting at Wikipedia:Comments in Local Time now called
dateDifference
, which you can set tofalse
to disable it. Gary King (talk) 17:27, 2 April 2009 (UTC)- Good man, thank you. –xeno (talk) 17:33, 2 April 2009 (UTC)
- What about an option to still use the 24-hour clock? Also, I suppose this is a matter of opinion, but I think it should default to 100% font size. Looks a little peculiar 5% smaller. –xeno (talk) 17:42, 2 April 2009 (UTC)
- (Just noticed the "day of week" thing too, something else I don't want - sorry to be difficult) - basically, perhaps a "vanilla" setting whereby the only thing changed in the datestamp is the time offset? –xeno (talk) 18:14, 2 April 2009 (UTC)
- You can change the size if you like. Personally, I like the smaller font size. Oren0 (talk) 07:42, 3 April 2009 (UTC)
- (Just noticed the "day of week" thing too, something else I don't want - sorry to be difficult) - basically, perhaps a "vanilla" setting whereby the only thing changed in the datestamp is the time offset? –xeno (talk) 18:14, 2 April 2009 (UTC)
- I think the smaller size is better, too. We had a short discussion about this earlier on this page; the default size was first 90%, which I was using from April 2008 to January 2009 or so, and then some people said that it was too small so I tried 100%. The problem with 100%, however, is that the date can actually be mistaken as part of the rest of the text if you just glance at it; it's easier to spot if its size is just a tad different from the rest. So I compromised with 95% font size. But yeah, you can change it for yourself personally if you want. Gary King (talk) 16:28, 3 April 2009 (UTC)
Possibility to transfer the gadget to other language
Hi, this gadget is fantastic. I wish I can also have this gadget in Wikipedias other than the English one. But the script is too complex for me, so I would like to know how to "translate" the script so that I can use it in other Wikipedia as well. --Quest for Truth (talk) 14:47, 15 June 2009 (UTC)
- Okay done. Check out the script at User:Gary King/comments in local time.js; at the top, there is
var language =
and then a list of terms. The terms on the left side of the colon (:) indicate the English version of the term, while the term on the right side will be what is actually shown; so just change the terms on the right side to translate the script to any language you want. Gary King (talk) 20:23, 15 June 2009 (UTC)
- There are more than just word-by-word translation. For example, in Chinese Wikipedia, "15:09,12 June 2009 (UTC)" is originally displayed like "2009年6月12日 (五) 15:09 (UTC)". See Calendar date for your interest. --Quest for Truth (talk) 08:20, 16 June 2009 (UTC)
- I don't know Chinese so I can't even begin to translate it to that. For other languages, though, they mostly just differentiate by the order of the date elements; the script is already capable of handling different ones. Just take a look at Wikipedia:Comments_in_Local_Time#Custom_settings and find dateFormat. Gary King (talk) 15:38, 16 June 2009 (UTC)
- Thanks for your reply, although I'm still a few steps away from success. I guess I need to modify the function
replace_text
slightly so that it is able to recognize a date in Chinese, but I don't know how. The default date format in the Chinese Wikipedia (and actually the same in Japanese Wikipedia) is "YYYY年M月D日 (W) HH:MM (UTC)", where 年, 月, 日 are three Chinese characters meaning year, month, day respectively. Weekday is given by default and written in Chinese character, but it should be redundant for the script. --Quest for Truth (talk) 18:38, 16 June 2009 (UTC) - Or I have missed something? I have copied the code in http://zh.wikipedia.org/wiki/User:Quest_for_Truth/comments_in_local_time_zh.js and modify it. Then I put the code below to http://zh.wikipedia.org/wiki/User:Quest_for_Truth/monobook.js
- Thanks for your reply, although I'm still a few steps away from success. I guess I need to modify the function
- I don't know Chinese so I can't even begin to translate it to that. For other languages, though, they mostly just differentiate by the order of the date elements; the script is already capable of handling different ones. Just take a look at Wikipedia:Comments_in_Local_Time#Custom_settings and find dateFormat. Gary King (talk) 15:38, 16 June 2009 (UTC)
- There are more than just word-by-word translation. For example, in Chinese Wikipedia, "15:09,12 June 2009 (UTC)" is originally displayed like "2009年6月12日 (五) 15:09 (UTC)". See Calendar date for your interest. --Quest for Truth (talk) 08:20, 16 June 2009 (UTC)
document.write('<script type="text/javascript" src="' + 'http://zh.wikipedia.org/wiki/User:Quest_for_Truth/comments_in_local_time_zh.js' + '&action=raw&ctype=text/javascript"></' + 'script>');
- Oh okay I see what you are trying to do now. Yeah, the
replace_text
is what you need to modify; replace it withreplace_text(document.getElementById(element_id), /(\d{4})年(\d{1,2})月(\d{1,2})日 \((.*)\) (\d\d):(\d\d) \(UTC\)/g, adjust_time);
, which might work. Then you'll also have to replacefunction adjust_time(original_timestamp, old_hour, old_minute, old_day, old_month, old_year, offset)
withfunction adjust_time(original_timestamp, old_year, old_month, old_day, day_of_the_week, old_hour, old_minute, offset))
Gary King (talk) 19:30, 16 June 2009 (UTC)
- Oh okay I see what you are trying to do now. Yeah, the
Error
This gadget does not show Saturdays. Every time someone posts something on a Saturday, it says "undefined". This may be just mine for some reason; is anyone else having this problem? Timmeh!(review me) 21:33, 17 June 2009 (UTC)
- I'm having the same problem. Dabomb87 (talk) 22:23, 17 June 2009 (UTC)
- Okay fixed. Gary King (talk) 22:58, 17 June 2009 (UTC)
- Thanks. I'm surprised nobody noticed that until now. Timmeh!(review me) 00:10, 18 June 2009 (UTC)
- The problem just started happening yesterday when I translated the script. Gary King (talk) 01:08, 18 June 2009 (UTC)
- Thanks. I'm surprised nobody noticed that until now. Timmeh!(review me) 00:10, 18 June 2009 (UTC)
- Okay fixed. Gary King (talk) 22:58, 17 June 2009 (UTC)
Getting two timestamps on the same line to format
In this RfC, in the second line of the introductory text, the second timestamp "The RFC started ... <timestamp>" does not format. After a bit of testing, I figured out that when there are multiple timestamps on one line, only the first one is formatted. Does anyone know how to fix this? Dabomb87 (talk) 01:30, 1 July 2009 (UTC)
- Yeah, this is how it works for now. I don't think I have time to work on it to make it format all dates in a line; maybe sometime down the road, but it's not a high priority at the moment considering that it's not a situation that happens often. Gary King (talk) 04:52, 27 July 2009 (UTC)
The "!important;" code in the monobook.css config options
Gary, a question: what does the change requiring "!important;" in the monobook.css code for custom font size do? I noticed that it had been changed after first noticing that the old code no longer worked. --Ckatzchatspy 20:00, 18 July 2009 (UTC)
- Yeah, you now require that you use
!important
for CSS changes made to this script. I know it's a nuisance to have to go change it, but it's better to have these kinds of changes fairly early on in the script's life than later on (only 9 people are modifying.localcomments
at the moment; I'll go ahead and notify them all now, which I should have done after making this change). The reason that this change was made is because theimportant
ensures that your change overwrites any custom ones made by the script. Originally, the script wrapped a<span>
tag around another one; it's not the cleanest way to do it, so I just recently merged the two together. I did this after noticing that the code acted differently in Internet Explorer (it didn't work at all, actually). Firefox, which is what I and I'm sure most of you guys use, act differently; it's more flexible regarding HTML, so I didn't notice any of these problems while using it. I'm on a Mac and just recently had access to a Windows machine, so that's when I got around to checking out my scripts in IE. Gary King (talk) 21:57, 18 July 2009 (UTC)
Strange behaviour in diff
Two questions 1) there's something strange here, it seems date is display:block or goes on a new line 2) what to do for localization on a foreign wiki? thanks --Lenore (talk) 21:24, 19 September 2009 (UTC)
- The date does not use display: block; it's inside a span, so by default it's display: inline. I don't see the problem that you are talking about (I assume you are referring to the "Class" section). To localize on a foreign wiki, simply follow the instructions under "Localization" that I just added here. Gary King (talk) 00:02, 20 September 2009 (UTC)
- Ah ok, maybe it goes only on a new line without block. Thank you for Loc --Lenore (talk) 16:09, 20 September 2009 (UTC)
- Resolved: it goes on a new line due to
white-space: nowrap;
; there could be some problems on little screens --Lenore (talk) 17:23, 20 September 2009 (UTC)- The script has been using nowrap for about a year now, without any complaints so far. I think this is because most people using the script browse Wikipedia primarily from their computers and not mobile devices, so the screen is wide enough that putting the entire timestamp, however long it may be, on one line isn't a problem. If you are using a mobile device to read Wikipedia and you are logged in to an account that uses this script, then there are several methods that you can use to shorten the timestamp so that if it's moved to its own line, it won't be very long; all of the options available to you are found here. For instance, you can set
dateDifference: false;
to shorten the timestamp. Gary King (talk) 17:53, 20 September 2009 (UTC)- I don't use a mobile device, but in effect that's only a little trouble. I don't think it really needs a fix --Lenore (talk) 19:14, 20 September 2009 (UTC)
- The script has been using nowrap for about a year now, without any complaints so far. I think this is because most people using the script browse Wikipedia primarily from their computers and not mobile devices, so the screen is wide enough that putting the entire timestamp, however long it may be, on one line isn't a problem. If you are using a mobile device to read Wikipedia and you are logged in to an account that uses this script, then there are several methods that you can use to shorten the timestamp so that if it's moved to its own line, it won't be very long; all of the options available to you are found here. For instance, you can set
- Resolved: it goes on a new line due to
- Ah ok, maybe it goes only on a new line without block. Thank you for Loc --Lenore (talk) 16:09, 20 September 2009 (UTC)
Daylight savings time ending quirk
Since daylight saving time in the US ended this past Sunday, the script has been adding a year to the relative time. For example, 02:29, 3 November 2009, which should display as 9:29 pm, 2 November 2009, last Tuesday (2 days ago) (UTC−6)
(as of the time at which I'm typing this) instead displays as 8:29 pm, 2 November 2009, Monday (1 year, 2 days ago) (UTC−6)
. Any way to fix this? Dabomb87 (talk) 01:53, 5 November 2009 (UTC)
- Is this happening to all timestamps for you? It isn't happening to me; I am in EST (-5 GMT), and DST is active here and ended the same time that it does in the US. Gary King (talk) 02:33, 5 November 2009 (UTC)
- It is happening with all timestamps. Do user preferences have anything to do with it? Dabomb87 (talk) 02:35, 5 November 2009 (UTC)
- Nope; the script uses your computer's timezone settings. The user preferences only affect dates in History pages. Gary King (talk) 02:41, 5 November 2009 (UTC)
- ...and therein lay the problem. It was my computer's date and time setting, which had the year set to 2010. Sorry about the disturbance. Dabomb87 (talk) 02:44, 5 November 2009 (UTC)
- Nope; the script uses your computer's timezone settings. The user preferences only affect dates in History pages. Gary King (talk) 02:41, 5 November 2009 (UTC)
- It is happening with all timestamps. Do user preferences have anything to do with it? Dabomb87 (talk) 02:35, 5 November 2009 (UTC)
Incorrectly adding "last"
I've just noticed that the script is prepending "last" to the day on timestamps. I skimmed through the code just now and I think that I spotted the bug. Alas, MediaWiki doesn't use line numbering for code listings, so bear with me as I post a somewhat large chunk of code here to identify the problem:
In function adjust_time:
// return 'today' or 'yesterday' if that is the case
if (year == today.getFullYear() && month == add_leading_zero(today.getMonth() + 1) && day == today.getDate())
var date = language['Today'];
else if (year == yesterday.getFullYear() && month == add_leading_zero(yesterday.getMonth() + 1) && day == yesterday.getDate())
var date = language['Yesterday'];
else if (year == tomorrow.getFullYear() && month == add_leading_zero(tomorrow.getMonth() + 1) && day == tomorrow.getDate())
var date = language['Tomorrow'];
else
{
// calculate day of week
var day_names = new Array(language['Sunday'], language['Monday'], language['Tuesday'], language['Wednesday'], language['Thursday'], language['Friday'], language['Saturday']);
var day_of_the_week = day_names[time.getDay()];
if (LocalComments.dateDifference)
{
// calculate time difference from today and the timestamp
today = new Date(today.getYear(), today.getMonth(), today.getDate());
time = new Date(time.getYear(), time.getMonth(), time.getDate());
var milliseconds_ago = today.getTime() - time.getTime();
var days_ago = Math.round(milliseconds_ago / 1000 / 60 / 60 / 24);
var difference, difference_word = '', last = '';
if (today.valueOf() >= time.valueOf())
{
difference = new Date(today.valueOf() - time.valueOf());
difference_word = language['ago'];
if (days_ago <= 7)
last = language['last'] + ' ';
}
Third line from the bottom: "if (days_ago <= 7)", shouldn't it be "if (days_ago >= 7)"?
— V = I * R (talk to Ohms law) 06:22, 17 January 2010 (UTC)
- No; "last", at least for me, means "the most recent Monday". Therefore, it will have to be within the last seven days. If it was >= 7, then any day older than seven days will be considered the "last", which is inaccurate. Gary King (talk) 19:51, 17 January 2010 (UTC)
- humm... OK, no problem. It's not a big deal regardless, it just strikes me as slightly strange to see, for example: "3:03 pm, 15 January 2010, last Friday (2 days ago) (UTC−5)" I guess that "last Friday" would mean January 8th, to me. But, like I said above it's no big deal, if this is the way it's intended to be I can easily just deal with it. Thanks for the script!
— V = I * R (talk to Ohms law) 20:18, 17 January 2010 (UTC)- I know that some people have their own way of interpreting "last Friday", "this Friday", and "next Friday", but I'm pretty strict with my own definitions. I consider "last Friday" to be the most recently passed Friday, "this Friday" to be the upcoming Friday", and so "next Friday" is the Friday following that, although I rarely use "next Friday" as that can certainly be confused with "this Friday". Gary King (talk) 20:21, 17 January 2010 (UTC)
- humm... OK, no problem. It's not a big deal regardless, it just strikes me as slightly strange to see, for example: "3:03 pm, 15 January 2010, last Friday (2 days ago) (UTC−5)" I guess that "last Friday" would mean January 8th, to me. But, like I said above it's no big deal, if this is the way it's intended to be I can easily just deal with it. Thanks for the script!
Error when viewing source
When I view source of a page I can't edit, this gadget causes an error “node is null” on the first line of function replace_text()
. This means that my personal JS doesn't run on such pages. I'm using Firefox 3.6 and Vector. Svick (talk) 12:32, 20 March 2010 (UTC)
- In my test account, I've got this gadget enabled, and switched to the Vector (beta) skin. I go to the Main Page and receive no messages in my JavaScript Console. This is in both Google Chrome 5 and Firefox 3.6. Gary King (talk) 18:23, 20 March 2010 (UTC)
- You're right, it seems this error happens only on some pages. Viewing source of the Main page works correctly for me too, but Template:Cite web doesn't. Svick (talk) 19:29, 20 March 2010 (UTC)
- Fixed Gary King (talk) 20:52, 20 March 2010 (UTC)
- Thanks. Svick (talk) 20:55, 20 March 2010 (UTC)
- Fixed Gary King (talk) 20:52, 20 March 2010 (UTC)
- You're right, it seems this error happens only on some pages. Viewing source of the Main page works correctly for me too, but Template:Cite web doesn't. Svick (talk) 19:29, 20 March 2010 (UTC)
Performance problem
Recently, every time I loaded a page with lots of signatures, I would get a Firefox popup informing me that a script was taking too much time. As I do a lot of editing on Template talk:Did you know, this was a major inconvenience. I solved the problem by using my own copy of User:Gary King/comments in local time.js from February 25, 2011. MANdARAX • XAЯAbИAM 20:11, 28 April 2011 (UTC)
- T:TDYK seems to load okay for me, with this script installed. It of course takes a few seconds longer than most pages (took about five seconds to load, similar to WP:ANI) but I didn't get the Firefox warning that you got. This is with the latest version of the script. Gary King (talk · scripts) 21:44, 28 April 2011 (UTC)
Request
I've been using this script for a while now and find it very helpful. Just one small request: would it be possible to add an option to always display absolute dates and not "yesterday" and "today" for yesterday and today's dates? Thanks. —Bruce1eetalk 08:25, 14 July 2011 (UTC)
- Uh sure, I guess, but it would just show "0 days ago" and "1 days ago" then. You could just enable "dateDifference" if you want to have no relative dates at all, depending on why exactly you want this. Gary King (talk · scripts) 23:11, 14 July 2011 (UTC)
- I don't want the date difference to show, which is why I have it set to "false". Currently I see your previous post on this page as "23:44, 28 April 2011 (UTC+2)", which is exactly what I want. Your last post on this page shows as "01:11, Today (UTC+2)", but I would like to see it as "01:11, 15 July 2011 (UTC+2)". Maybe I'm just not using the settings correctly – please have a look at my vector.js. —Bruce1eetalk 06:12, 15 July 2011 (UTC)
Javascript error - mw.config is null or not an object
I'm running IE8 and I'm getting a javascript error from this script and curious as to what might be happening. I use Firefox at home and don't remember the error there (but don't know for certain). The two errors I'm getting are:
Message: 'mw.config' is null or not an object Line: 100 Char: 2 Code: 0 URI: http://wiki.riteme.site/w/index.php?title=User:Gary_King/comments_in_local_time.js&action=raw&ctype=text/javascript Message: Object doesn't support this property or method Line: 14 Char: 1 Code: 0 URI: http://wiki.riteme.site/w/index.php?title=User:Gary_King/comments_in_local_time.js&action=raw&ctype=text/javascript
Any idea what might be going on? I tried enabling this as a gadget and by adding it to my custom js file and both have the same error. Appreciate any thoughts! Ravensfire (talk) 15:40, 31 August 2011 (UTC)
- I can confitm that enabling this gadget in preferences breaks all other scripts for IE8, see WP:Village pump (technical)/Archive 94#JavaScript problems in IE8 (later changed to point to archive). I'm not sure why it happens but I could take a look... — AlexSm 16:22, 21 October 2011 (UTC)
- I'll hopefully check it out in the upcoming weeks. I don't have access to IE-anything, so it'll take some time. Gary King (talk · scripts) 18:50, 27 October 2011 (UTC)
- Meanwhile you could ask any sysop with IE to confirm this behaviour and update MediaWiki:Gadget-CommentsInLocalTime with text "incompatible with Internet Explorer". — AlexSm 19:27, 27 October 2011 (UTC)
- Update: the error is caused by
var mw = ...
: in IE this redeclaresmw
asundefined
even though this line is never "executed". See stackoverflow thread for some info. — AlexSm 20:06, 27 October 2011 (UTC)
- Update: the error is caused by
- Should be fixed now. Someone tell me if it isn't. It wasn't simply a matter of implementing the fix since I wanted to test it out, since almost all my other scripts use the same unsafeWindow code. I managed to get my hands on a friend's Windows 7 computer, but it had IE9 (the latest IE), which already resolved this bug, so I had to specifically find someone with IE8. Managed to do so, problem seems to be solved now. Gary King (talk · scripts) 19:51, 3 November 2011 (UTC)
- Just noticed you'd fixed the problem, so I've enabled the gadget again and it's working. Thanks for the fix! Ravensfire (talk) 18:01, 16 November 2011 (UTC)
WikiProject
When I enable "Change UTC-based times and dates, such as those used in signatures, to be relative to local time", it seems to "break" WikiProjectBannerShell or WikiProject (or something related to them) by always forcing them to expand. Talk:Santa_Fe_Trail and Talk:AGCO • Sbmeirow • Talk • 04:43, 2 October 2011 (UTC)
- Doesn't happen to me, and this is the first that I've heard of this after this script has been available for a few years now and in use by a few thousand people. Do you have any other scripts installed? I suggest installing the script version, by following the instructions here—be sure to uninstall the script from Gadgets first—and see if that helps. Don't forget to bypass your cache, also, which usually just requires that you click on your browser's "refresh" button. Gary King (talk · scripts) 05:28, 2 October 2011 (UTC)
- I have been clicking the refresh icon in 64-bit IE 9 after every change that I made, before and after you left the comment. Prior to leaving my original comment, I did screen captures of all my settings, then changed ALL my setting back to the default, then I filled in my settings again from the left tab to right tab. The problem came back after I enabled some combination of gadgets. Anyway, after you replied, I started disabling and enabling other gadgets, and the problem finally went away, but then it was going away and coming back but not always on the same enable/disabling of some other gadget. At some point, I did a wikipedia purge (via the purge gadget) and the problem went away. I have been enabling/disabling various gadgets and can't make the problem come back. I'll get back to you if it starts happening again and/or if I can narrow down the cause. • Sbmeirow • Talk • 06:18, 2 October 2011 (UTC)
- By the way, back when I had the problem, if I logged out of wikipedia, and opened up a fresh browser screen the problem wouldn't show up in the above talk pages, but as soon as I logged back into wikipedia and went back to those talk pages, then it showed up again. • Sbmeirow • Talk • 06:22, 2 October 2011 (UTC)
Mediawiki update has broken this gadget
It seems like the update to 1.18 has broken this gadget, at least for me. —Akrabbimtalk 17:25, 5 October 2011 (UTC)
- Works for me. Does installing the script version fix it for you? Gary King (talk · scripts) 20:34, 5 October 2011 (UTC)
- Nope. I am certain that it worked yesterday, before the update. —Akrabbimtalk 20:53, 5 October 2011 (UTC)
- Try uninstalling other gadgets and scripts to ensure that none are interfering with this one. Check your browser's Error Console (in Firefox, go to Tools -> Web Developer -> Error Console) to see if there are any Javascript errors that are relevant to the script. I just checked my test account, which is always fresh (no gadgets/scripts installed), and checked a discussion page, timestamps looked normal. Enabled the gadget, refreshed, timestamps were updated to use the new format, as expected. This was in the Vector skin, on the test account. I personally use the Monobook skin on my own account. Gary King (talk · scripts) 20:57, 5 October 2011 (UTC)
Commons
Can this be used at Commons? —danhash (talk) 18:52, 26 October 2011 (UTC)
- I made a copy of the javascript code in my userspace in commons so I could use it over there. See commons:User:Akrabbim/vector.js. —Akrabbimtalk 22:51, 26 October 2011 (UTC)
- You don't have to copy the code to Commons. If you do, then you won't receive any of the updates that are made to the code over here. Just use:
importScriptURI('http://wiki.riteme.site/w/index.php?title=User:Gary_King/comments_in_local_time.js&action=raw&ctype=text/javascript')
- Oh, I didn't know you could import scripts from outside the project. Thanks. —Akrabbimtalk 19:27, 27 October 2011 (UTC)
Not sure ?
Not sure what I'm not doing right. MediaWiki:Gadget-CommentsInLocalTime.js / My User:.js Page Hopefully you can shed some light.
Thanks... Mlpearc powwow 04:00, 16 November 2011 (UTC)
- Should work, if you've enabled the gadget in your account. Are you getting any JavaScript errors? Is "importScriptURI" even defined in the default MediaWiki installation? Gary King (talk · scripts) 08:51, 16 November 2011 (UTC)
- I would think so other gadgets relying on "importScriptURI" are working, I'm not getting any errors everything seems to be working fine, the time stamp in a signature just isn't getting changed. Mlpearc powwow 17:31, 16 November 2011 (UTC)
- I see the problem. On here the timestamp ends in PST. I assume that there's a MediaWiki setting that defaults all timestamps to that timezone? The script only works on UTC timestamps at the moment, like how they appear on Wikipedia. I don't know how much work it would take to convert the script; but perhaps it'd be easier to change your wiki to UTC timestamps, and then enable Comments in Local Time by default to all users? I don't know how realistic an option that would be, though, so let me know. For now, though, I think that to convert the script, it'd require too much work since I'd then have to tell the script every single existing timezone (PST, EST, etc.) so that it doesn't just work with PST and UTC. Which seems like too much work for now. Gary King (talk · scripts) 21:27, 16 November 2011 (UTC)
- You're right, but it wasn't a MediaWiki setting it was in the wiki's LocalSettings.php It's an administrative setting availible for all wiki's $wgLocaltimezone :P so I'd hold off on the patch I guess it would be moot point to have both this set and your script. Thank you very much for your time a help, if you ever need a place to test you're welcome at EFD. (now I'll go work on Editnotices ) Mlpearc powwow 03:27, 17 November 2011 (UTC)
I am a childrens rights activist
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 (talk • contribs) 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
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 (u • t • c) 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 (u • t • c) 23:54, 17 March 2013 (UTC)
Nasty bug on Commons (source of file page disappears)
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
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
Hi.
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)
- 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) - The function
convertMonthToNumber
uses the javascript date object to convert the month. But javascript doesn't accept localized monthnames.
- Remaining issues:
- 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 )? - 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. - 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
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
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
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:
- 22:18, 5 November 2024 (UTC)
- 22:18, November 5, 2024 (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)
- Gary, I mostly notice it on history pages, and I often copy and paste stuff from history pages into talk pages or logs
- 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)
- 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)
how it works
I can't understood this... My time is not display properly please help me....NehalDaveND (talk) 02:14, 7 March 2014 (UTC)
Customization
@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)
- 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)
Missing time differential
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>
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
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"
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
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:
importScript("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 ?
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)
Spacing
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)
A few errors
“Today” and “yesterday” are capitalized when they shouldn’t be (example).
And shouldn’t it show the actual time zone instead of “UTC+X”? Also, “a.m.” and “p.m.” should have full stops in them.
Aside from that, this is a very neat gadget.Interqwark talk contribs 10:18, 14 June 2018 (UTC)
Further customizing comments in local time
Cross-post from Wikipedia:Village pump (technical)#Further customizing comments in local time, where I'm relying more on replies since the last post here was way back in June of last year.
I have the following in my vector.js: LocalComments = { dateDifference: false, dateFormat: 'mdy', timeFirst: false, twentyFourHours: false, dayOfWeek: false, dropDays: 0, dropMonths: 0 };
This changes signature display for me from 2:21 pm, 9 March 2019, Saturday (12 days ago) (UTC−8)
to March 9, 2019, 2:21 pm (UTC−8)
. I want to further customize it to capitalize the AM/PM and remove the time zone (UTC -X), since I know that all times are in my time zone of Pacific. Is that possible? CC: Redrose64. They directed me here after I asked them on their talk page here here. Amaury (talk | contribs) 05:41, 23 March 2019 (UTC)
- Copy the contents of this page to User:Amaury/comments in local time.js, then import it to User:Amaury/vector.js by adding
importScript('User:Amaury/comments in local time.js');
Gary (talk · scripts) 18:38, 23 March 2019 (UTC)- @Gary: Thank you very much. While I'm here, I might as well ask a couple more questions, if that's not a problem. That way, if I want to this in the future, no matter how soon, I can just get all my answers now rather than have to come back and ask. You might be familiar with a forum software platform called XenForo. It uses a feature called relative time. So for a post at, say, 9:30 AM, you'll see:
- 59 minutes ago
- Today at 9:30 AM
- Yesterday at 9:30 AM
- Sunday at 9:30 AM
- @Gary: Thank you very much. While I'm here, I might as well ask a couple more questions, if that's not a problem. That way, if I want to this in the future, no matter how soon, I can just get all my answers now rather than have to come back and ask. You might be familiar with a forum software platform called XenForo. It uses a feature called relative time. So for a post at, say, 9:30 AM, you'll see:
- You get the idea. Once the post is a week old, it changes to only the date. Of course for me, I would probably want to keep the time. I don't want mine to be that precise, so I would start with that second item in the list. So my question is can I have "at" instead of a comma? Second, Wikipedia already uses the "today" and "yesterday" terms, but once "yesterday" passes, can it change to the day and time rather than the date and time? And then once a week passes, the date and time? Ultimately, using my example in my OP above, this would be what I'm looking for, if it's possible:
- Today at 2:21 PM
- Yesterday at 2:21 PM
- Saturday at 2:21 PM
- March 9, 2019 at 2:21 PM
- You get the idea. Once the post is a week old, it changes to only the date. Of course for me, I would probably want to keep the time. I don't want mine to be that precise, so I would start with that second item in the list. So my question is can I have "at" instead of a comma? Second, Wikipedia already uses the "today" and "yesterday" terms, but once "yesterday" passes, can it change to the day and time rather than the date and time? And then once a week passes, the date and time? Ultimately, using my example in my OP above, this would be what I'm looking for, if it's possible:
- Thanks in advance, and no rush on responding or getting around to testing this. It's of course not urgent. Amaury (talk | contribs) 20:16, 23 March 2019 (UTC)
- I won't be able to help you with any of that, unfortunately. If it was a small request like the previous one, I could help, but this is too big for me. This script isn't so simple to edit for major changes like that, especially because of the many configuration options available, so a lot would have to be taken into account on each change. I also haven't worked on the script in five years, so I'm no longer familiar with it. Gary (talk · scripts) 03:42, 24 March 2019 (UTC)
- @Gary: No worries. Thanks. Amaury (talk | contribs) 05:06, 24 March 2019 (UTC)
- I won't be able to help you with any of that, unfortunately. If it was a small request like the previous one, I could help, but this is too big for me. This script isn't so simple to edit for major changes like that, especially because of the many configuration options available, so a lot would have to be taken into account on each change. I also haven't worked on the script in five years, so I'm no longer familiar with it. Gary (talk · scripts) 03:42, 24 March 2019 (UTC)