Jump to content

Template talk:Time ago/Archive 1

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Archive 1

Suggested change

{{editprotected}} I am recommending the first occurrence of "3600" in the template be changed to "7200" (not the second!). The line currently reads:

{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 3600     ) | 1 | 0 }}+

The new line would look like this:

{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 7200     ) | 1 | 0 }}+

Result of Change

The result of this change would be that all "edited n hours ago" less than 2 hours would appear as minutes instead of hours. Currently, both 61 minutes and 119 minutes show as "1 hour" and 59 minutes shows as just that. After this change, times like 73 minutes ago and 115 minutes ago will appear, but 125 will be "2 hours" still.

The idea came because I am watching the page Tatco where somebody put a Template:Under construction. Almost two hours later it still said "edited 1 hour ago". I do not think such a change would be controversial because it would not alter the appearance of the template and only improves its precision. ZabMilenko 05:37, 3 June 2009 (UTC)

Sounds reasonable. Could the same argument be applied for the other orders of magnitude, e.g. use mins up to 120, hours up to 48, days up to 60, etc.? — Martin (MSGJ · talk) 07:39, 3 June 2009 (UTC)
It very well could actually; "51 days" instead of "1 months" would be more useful, as would be "17 months" compared to "1 years". The following table is for the figures: ZabMilenko 08:15, 3 June 2009 (UTC)
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 120      ) | 1 | 0 }}+
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 7200     ) | 1 | 0 }}+
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 172800   ) | 1 | 0 }}+
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 5356800  ) | 1 | 0 }}+
{{#ifexpr: floor( abs( {{#time:U}} - {{#time:U| {{{1|}}} }} ) / 63115200 ) | 1 | 0 }}
Yes, this might better reflect common usage. For example, how old does a baby have to be before his/her age is counted in years rather than months? — Martin (MSGJ · talk) 10:36, 3 June 2009 (UTC)
2, but that is a trick question, because some societies count the baby's age from conception, not from birth, although after one year after birth, the gestation period is counted as one full year. 199.125.109.102 (talk) 20:27, 3 June 2009 (UTC)
 Done — Martin (MSGJ · talk) 22:02, 3 June 2009 (UTC)

Protection level

I came to this page via Category:Wikipedia protected edit requests. For editing, the direct protection on the page would only make it semi-protected (reduced from fully protected due to a request). However, it is also transcluded on Wikipedia:Cascade-protected items and User:Hersfold/Lockbox, which are fully protected with the "cascading" option. Brian Jason Drake 14:41, 26 January 2010 (UTC)

I should explain that, in the table in the category, the only thing I can see is:

Modified by Happy-melon on 2009-06-04: “reduce to semi, per request”

Yet the page is fully protected. This is confusing. Brian Jason Drake 14:52, 26 January 2010 (UTC)
You seem to have worked it out. Although the page is only directly semiprotected, its transclusion on the cascade-protectedWikipedia:Cascade-protected items gives it full protection. — Martin (MSGJ · talk) 17:14, 26 January 2010 (UTC)

Specify units

It would be nice if this template could take a parameter to specify which units are used. There are occasions when one unit (e.g. hours) is needed. — Martin (MSGJ · talk) 09:00, 18 July 2009 (UTC)

I made changes to the sandbox that hopefully implement this. Also, I added weeks in between the days and months but not sure how I like it. If removed, it should definitely remain as an "optional" magnitude. Was this what you were thinking of? ZabMilenkoHow am I driving? 04:15, 20 July 2009 (UTC)
I've made a few changes and simplified the code somewhat. — Martin (MSGJ · talk) 20:02, 20 July 2009 (UTC)
Way nicer. I am used to switch only taking integers, so I didn't even think to try strings. The test cases look good too. ZabMilenkoHow am I driving?

{{editprotected}} I want to enhance this template, but before I do that, it should be updated to the current sandbox version (that adds error message and magnitude parameter as discussed above). Svick (talk) 14:09, 26 January 2010 (UTC)

Doesn't your version stop this template working for future times? — Martin (MSGJ · talk) 17:20, 26 January 2010 (UTC)
It's not my version, but yes, it didn't work for future times. I fixed it, so it should be okay now. Svick (talk) 17:31, 26 January 2010 (UTC)
Sorry, got you mixed up with the editor above!  Synchronised with sandbox. — Martin (MSGJ · talk) 18:42, 26 January 2010 (UTC)

min_magnitude

{{editprotected}} In {{Start date and age}} (that uses this template), returning values like “5 hours ago” doesn't make sense, because only the date (not time) is specified, “0 days ago” would be more appropriate. Setting magnitude=days wouldn't be a good solution, because it would create values like “1000 days ago” (instead of the better “2 years ago”). Because of this, I added min_magnitude parameter to the sandbox, that should solve this issue. Could some admin, please, update this template from the sandbox version? Thanks. Svick (talk) 20:07, 26 January 2010 (UTC)

I like the idea but I've been trying to do some streamlining of the code. Please let me know if it's still working correctly, and if you like my approach. — Martin (MSGJ · talk) 20:00, 27 January 2010 (UTC)
The current version supports setting magnitude=weeks, but it doesn't use weeks when it decides the unit itself. I added weeks to /core and sandbox, and I think that everything works as it should now. Svick (talk) 20:27, 27 January 2010 (UTC)
 updated — Martin (MSGJ · talk) 21:14, 27 January 2010 (UTC)
Thanks. Svick (talk) 21:24, 27 January 2010 (UTC)

Proper plural

{{editprotected}} Hello, would someone be able to replace this template's code with this from Template:Time ago/core/sandbox. This code is able to find out if it's one second, or more seconds aand so on and thereby kills the "(s)", which isn't needed most of the time. Thank you, --The Evil IP address (talk) 17:53, 14 March 2010 (UTC)

Not done: {{edit protected}} is not required for edits to unprotected pages, or pending changes protected pages. — Martin (MSGJ · talk) 17:57, 14 March 2010 (UTC)
It's protected via cascading protection of User:Hersfold/Lockbox & Wikipedia:Cascade-protected items. --The Evil IP address (talk) 18:39, 14 March 2010 (UTC)
(Sorry for my stupidity.) This sounds like a good idea. I haven't had a chance to check the code in detail yet, but I have the feeling that it should be simpler to accomplish this. Let's see if anyone else has a comment and if I haven't come up with a better solution in a few days then I'll happily apply your edit. — Martin (MSGJ · talk) 11:03, 15 March 2010 (UTC)
This is an important idea. I can't understand the code, but the pseudo-code is really simple: if num <> 1: append "s" to unit. 0 days, 1 day, 2 days, etc. 0 minutes, 1 minute, 2 minutes, etc. +mt 17:39, 20 March 2010 (UTC)
Yes, it is a simple idea and I think the proposed code runs fine. But it is not efficient because it is effectively doing the calculation twice and a good template shouldn't do it this way. Anyway I haven't had time to think of a better way to do it, so I will implement the request now and then probably return to this problem at a later date. — Martin (MSGJ · talk) 17:55, 20 March 2010 (UTC)
Actually I'm not sure if the code is working properly. {{Time ago|Nov 6 2008|min_magnitude=years}} produces 16 years ago. — Martin (MSGJ · talk) 18:01, 20 March 2010 (UTC)
{{editprotected}}
{| class="wikitable" style="float:right;font-size:smaller"
! Delta !! Current !! Sandbox
|-
| -2 minutes || {{Time ago/core|time={{#time:c|-2 minutes}}|auto_magnitude_num=1}} || {{Time ago/core/sandbox|time={{#time:c|-2 minutes}}|auto_magnitude_num=1}}
|-
| -90 seconds || {{Time ago/core|time={{#time:c|-90 seconds}}|auto_magnitude_num=1}} || {{Time ago/core/sandbox|time={{#time:c|-90 seconds}}|auto_magnitude_num=1}}
|-
| -1 minute || {{Time ago/core|time={{#time:c|-1 minute}}|auto_magnitude_num=1}} || {{Time ago/core/sandbox|time={{#time:c|-1 minute}}|auto_magnitude_num=1}}
|-
| +0 minutes || {{Time ago/core|time={{#time:c|+0 minutes}}|auto_magnitude_num=1}} || {{Time ago/core/sandbox|time={{#time:c|+0 minutes}}|auto_magnitude_num=1}}
|-
| +1 minute || {{Time ago/core|time={{#time:c|+1 minute}}|auto_magnitude_num=1}} || {{Time ago/core/sandbox|time={{#time:c|+1 minute}}|auto_magnitude_num=1}}
|-
| +90 seconds || {{Time ago/core|time={{#time:c|+90 seconds}}|auto_magnitude_num=1}} || {{Time ago/core/sandbox|time={{#time:c|+90 seconds}}|auto_magnitude_num=1}}
|-
| +2 minutes || {{Time ago/core|time={{#time:c|+2 minutes}}|auto_magnitude_num=1}} || {{Time ago/core/sandbox|time={{#time:c|+2 minutes}}|auto_magnitude_num=1}}
|}
It's not. The problem is that even though it's displaying just "1", it's passing 1.576165931503 or so to the plural function. The "1 second ago" case is also broken due to invalid syntax in the #expr. I also note that, if fixed or the delta is exactly 1 minute, it will still incorrectly display "1 minute' time" instead of "1 minute's time". I've adjusted Template:Time ago/core/sandbox to correct all these issues. It also happens to correct the issue mentioned above that the calculation was being done twice.
BTW, if you want to make test cases, one easy way is to do something like {{Time ago|{{#time:c|-1 second}}}} ⇒ 1 second ago, although it will occasionally screw up if the various #time calls within the template end up happening in different clock-seconds (e.g. at 12:00:00.9995 and 12:00:01.0003). Anomie 17:32, 4 June 2010 (UTC)
Please use the {{editsemiprotected}} template only when a change has been agreed and the specific text to be changed has been decided. To look for help editing a template contact somebody who is familiar with templates or ask at requested templates. - EdoDodo talk 16:46, 5 June 2010 (UTC)
Whatever. There's no controversy, the edit just corrects the broken change above, and you apparently didn't even read the discussion above since you are complaining about {{editsemiprotected}}. And if you were really paying attention, you might notice that I am someone who is familiar with templates. But hey, if you want to pettifog instead of doing anything useful, I really don't care. Maybe someday someone who actually knows what is going on will revive this suggested change. Anomie 13:59, 6 June 2010 (UTC)
Really sorry, you're right, I didn't read the discussion properly and I thought you were asking somebody to make the changes, not just asking somebody to copy the text from the sandbox. I've re-enabled the template, so hopefully an admin will sort this out soon. - EdoDodo talk 14:11, 6 June 2010 (UTC)
No problem, thanks. Anomie 16:36, 6 June 2010 (UTC)
 implemented Thanks for working on this — Martin (MSGJ · talk) 16:53, 6 June 2010 (UTC)

Pages using this template need to be purged regularly

Is there any way to ensure that pages using this template are purged regularly? I went to Foxit Reader and it said something like "Stable release ... (May 3, 2012; 2 days ago)" when May 3 is clearly more than 2 days ago. Can such pages be purged daily? Or would this require a change to the software? Set theorist (talk) 06:36, 14 May 2012 (UTC)

Edit request

Please add

{{#ifeq: {{{purge|}}}|yes|{{#ifeq: {{{1|}}}|{{REVISIONTIMESTAMP}}|<span class="plainlinks">([{{fullurl:{{FULLPAGENAME}}|action=purge}} purge])</span>|}}|}}

to the bottom of the template. This would, if the purge= parameter was set to yes, there would be an option to purge the page. This was suggested by MSGJ at Template talk:Userspace draft. Example:

33 days ago (purge)

Thank you. —HueSatLum 22:50, 30 May 2012 (UTC)

What is the purpose of {{#ifeq: {{{1|}}}|{{REVISIONTIMESTAMP}}? — Martin (MSGJ · talk) 06:54, 31 May 2012 (UTC)
Sorry, you don't need that. The new suggestion is:
{{#ifeq: {{{purge|}}}|yes|<span class="plainlinks">([{{fullurl:{{FULLPAGENAME}}|action=purge}} purge])</span>|}}
Thanks, —HueSatLum 22:19, 31 May 2012 (UTC)

 Done: please let me know if there are any problems. Thanks. Chris Cunningham (user:thumperward) (talk) 09:23, 1 June 2012 (UTC)

Trailing space

It looks like the template can leave a trailing space:

  • ({{time ago|1 jan 2012}}) → (12 years ago)
  • (0 seconds ago)

To me this looks like an undesired feature. -DePiep (talk) 10:14, 13 June 2012 (UTC)

Looks like it is in this:
 ...
    |#default= 0
   }}
  }}
 }} {{#ifeq:{{{purge|}}}|yes|<span class="plainlinks">([{{fullurl:{{FULLPAGENAME}}|action=purge}} purge])</span>|}}<noinclude>{{documentation}}</noinclude>

The final line has:

 }} {{#ifeq:{{{purge ...

When a purge link is requested and added, the space acts as expected, and is a nice line-breaking point. But when no purge is requested, it should be a final space and so removed (whitespace behavour). Instead, the unused &ltspan> still is detected,andso the space is not the final whitespace character and stays.

Possible sol;ution: add the space as &amp;x20; right before the purge-<span>, remove the current one. -DePiep (talk) 10:31, 13 June 2012 (UTC)

Edit request

Issue: trailing space may show up (see above). Solution reasoned & tested through sandbox.
Request: Please copy {{Time ago/sandbox}} code (or the simple diff effect) to the live version.
What changes? See the diff Take a look at the final #ifeq ... construct. Before is a regular space. Code change is: 1. remove that space, and 2. add right before the <span> tag the code &amp#x20;. For the reasoning see above.
This sandbox version is tested in {{time ago/testcases}}, first section. Also tested: line breaking effects before/after. -DePiep (talk) 10:47, 13 June 2012 (UTC)

Done Although your analysis about an "unused <span>" seems off, the solution is correct. Anomie 14:54, 13 June 2012 (UTC)
Sure you would discribe it different, and I am also sure you do understand what it says. -DePiep (talk) 15:40, 13 June 2012 (UTC)

floor'ing vs rounding

Why are we not rounding? It seems to produce more accurate results than floor'ing. See the Template:time ago/core/sandbox sandbox and Template:time ago/core/testcases. Cpetty-wiki (talk) 04:09, 21 October 2012 (UTC)

Sortable tables

This template doesn't sort correctly in sortable tables. If you sort a column whose cells use this template, then you'll get alphabetic sorting (i.e. it'll sort in an order like "2 days ago, 2 hours ago, 2 years ago, 3 days ago, 3 hours ago, 3 years ago"). As much as I'd like to deconstruct this template and figure out how it works in order to fix this issue, I don't have the time to do that at the moment. Is there anyone around who already understands how this template works, and might be able to fix this issue? Perhaps it is as easy as adding in some invisible text, like the {{dtsh}} / {{ntsh}} templates do. Thanks. ‑Scottywong| gossip _ 01:51, 10 January 2013 (UTC)

Ideally, the table cell should have an appropriate value in its data-sort-value property:
Column 1 Column 2
1 16 years ago
two 4 hours ago
3 14 years ago
HTH. Anomie 03:22, 10 January 2013 (UTC)
Thanks, that does help. I still think it would be ideal if this template would automatically sort correctly without setting the data-sort-value property of the cell, but this works for now. ‑Scottywong| chat _ 23:05, 10 January 2013 (UTC)
The really nice thing about data-sort-value is that it's not an awful, deplorable hack. Anomie 02:46, 11 January 2013 (UTC)
Oh, don't be such a code snob. Long strings of invisible numbers can come in handy every once in awhile... :p Thanks again. ‑Scottywong| gab _ 05:22, 11 January 2013 (UTC)

Coding in other languges

Hi I would like some help to change the codes so it works in other languges it works but you have use the English months and days. But I would like to change the codes so it allows them to write the months and days in there languges please Skybliei (talk) 10:56, 12 April 2013 (UTC)

Why? This is the English Wikipedia... ‑Scottywong| prattle _ 13:36, 12 April 2013 (UTC)

Number of days in a month

This template assumes a 31 day month, but the average number of days in a month is 30.436875 (see Month#Julian and Gregorian calendars). I suggest we change 5356800 (representing 2 months) to 5259492. A ~27 hour difference. Cpetty-wiki (talk) 01:16, 21 October 2012 (UTC)

And same goes for the time ago/core. We should change 2678400 to 2629746 in that template. Cpetty-wiki (talk) 01:24, 21 October 2012 (UTC)
I agree the count of months should be improved. I came here after seeing Gibraltarpedia today, 13 July 2013, saying "Launched 12 July 2012; 11 months ago". {{time ago|2012-7-7}} also returns "11 months ago" today when it's actually 12 months and 6 days. And {{time ago|2011-8-1}} says "22 months ago" when it's 23 months and 12 days. PrimeHunter (talk) 23:08, 13 July 2013 (UTC)

Edit request on 30 September 2013

I am requesting that this template be updated to use a non-breaking space between the number and the units (year, month, week, day, hour, minute, second). This would replace the current breaking space that is generated by Template:Plural (which now has an option to use non-breaking space). A breaking space would still be used between the units and "ago" (similar to the output of Template:Start date and years ago). The template to be updated is Template:Time ago/core and the updated code can be found in Template:Time ago/core/sandbox (please do not copy Template:Time ago/sandbox which was temporarily updated to use the sandbox version of /core in order to display examples and test cases). The output of the following examples was placed inside a narrow <div> to force a line break.

Example Current output Sandbox output
{{Time ago|-13 months|min_magnitude=years}}
1 year ago
1 year ago
{{Time ago|-32 days|min_magnitude=months}}
1 month ago
1 month ago

Additional examples can be found at Template:Time ago/testcases#Non-breaking space. -- Zyxw (talk) 03:59, 30 September 2013 (UTC)

 Done — Martin (MSGJ · talk) 12:09, 2 October 2013 (UTC)

Spell out numbers less than 10

It is usually improper grammar to use 1 to 9 in prose; they should be spelt out. I wouldnt expect that change to have a negative impact, but haven't looked at all the instantiations of this template yet. The one case where I saw the problem was on Template:Userspace_draft, where names rather than numerals would be an improvement. John Vandenberg (chat) 01:33, 7 October 2013 (UTC)

This is technically possible, with the immediately-obvious downside of increased complexity implying reduced speed. But should it be done? Besides showing that certain numbers outside the 1-9 range may also be spelt out, MOS:NUMERAL gives a number of exceptions, so it's not a universal rule. Directly relevant is the first bullet, since {{time ago}} could potentially be used in infoboxes. I know it's not used as a subtemplate of {{birth date and age}}, but there may be related templates which do use {{time ago}}. --Redrose64 (talk) 07:10, 7 October 2013 (UTC)
The page caching makes the complexity and render speed of little consequence.
The width of the template result is an interesting consideration that I hadn't considered, and your concern about use in infoboxes is spot on. A bit of digging around reveals that one of the primary uses of this template is the software age templates (Template:Latest stable software release) where the text already wraps in the infoboxes (see Firefox), and sure enough the call is found in {{start date and age}} which could be used in many other ways in infoboxes and tables.
Fwiw, the longest spelt out number less than 10 will be 'seven' (for proportional widths), and also 'eight' for mono-spaced fonts, which is only four additional characters (as opposed to one numeral). In most cases, four additional characters won't cause the text to wrap. The layout in the Firefox infobox is already nasty, and a redesign is needed to present the info more clearly. John Vandenberg (chat) 07:59, 8 October 2013 (UTC)
Stylistically, for a single use it is preferable to write numbers less than 10 in words. However if there are multiple uses of this template (e.g. in an infobox like Firefox) it is awkward to see 21 days ago adjacent to seven days ago. A consistent approach is better. As it is not possible to detect when the template is used in prose and when it is used in a table, I would probably oppose a blanket change. However perhaps it would be possible to add an option to the template for using words when desired? — Martin (MSGJ · talk) 08:21, 8 October 2013 (UTC)
Adding an option (default: disabled) would be a good way to approach this. John Vandenberg (chat) 08:46, 9 October 2013 (UTC)
@John Vandenberg, Redrose64, and MSGJ: I've just created Module:NumberSpell, which spells out numbers from 0 to 100. I think it would be a good idea to use it in Module:TimeAgo, but what would be the best way of doing it? Spell 1-9 out by default, and spell out other numbers if an optional parameter is set? Or make all spelling out optional? — Mr. Stradivarius ♪ talk ♪ 20:07, 13 January 2014 (UTC)
Thank you! I think an option is necessary. spellout=yes/no/auto, where 'auto' spells out 1-9. Default to 'no' is the easiest option - no forced changes, so no fallout is possible. If you want to make 'auto' the default, after you implement it we'll need to quickly spot check all usages to be sure it isn't buggering up layouts, and be attentive to any complaints. John Vandenberg (chat) 00:18, 14 January 2014 (UTC)

Ok, I've added two parameters to {{time ago/sandbox}} - spellout and spelloutmax. spellout can be set to "yes" or "auto" like you described above, and is off by default. spelloutmax is the maximum number that can be spelled out. Here are a few examples:

  • {{time ago/sandbox|June 1, 2009|spellout=yes}} → fifteen years ago
  • {{time ago/sandbox|June 1, 1999|spellout=yes}} → twenty-five years ago
  • {{time ago/sandbox|June 1, 2009|spellout=auto}} → 15 years ago
  • {{time ago/sandbox|June 1, 1999|spellout=auto}} → 25 years ago
  • {{time ago/sandbox|June 1, 1989|spellout=yes|spelloutmax=15}} → 35 years ago
  • {{time ago/sandbox|June 1, 1989|spellout=yes|spelloutmax=25}} → 35 years ago

I'll leave this open for comments a little while longer and then implement it if there are no issues. It would be easy to switch the template to use |spellout=auto by default if people would like that better. — Mr. Stradivarius ♪ talk ♪ 13:15, 14 January 2014 (UTC)

Note - I added this to the live template yesterday, so this can now be rolled out to other templates and articles. — Mr. Stradivarius ♪ talk ♪ 07:43, 29 January 2014 (UTC)

Suggesting to Module:TimeAgo

I will suggest that local numberSpell = require('Module:NumberSpell')._main is moved to the place where the function from the module is used. In this way the module is only transcluded if it is used, e.g.:

if ( spell_out == 'auto' and 1 <= result_num and result_num <= 9 and result_num <= ( spell_out_max or 9 ) )
		or ( yesno( spell_out ) and 1 <= result_num and result_num <= 100 and result_num <= ( spell_out_max or 100 ) )
	then
                local numberSpell = require('Module:NumberSpell')._main
		result_num_text = numberSpell( result_num )
	else
		result_num_text = tostring( result_num )
	end

Christian75 (talk) 10:05, 30 January 2014 (UTC)

This is an interesting suggestion. You're right that doing things this way wouldn't load the NumberSpell module unless it was used; however, I don't think that it would have any appreciable effect on performance compared to the current module. I'll ask at WT:Lua about that just in case I'm wrong. — Mr. Stradivarius ♪ talk ♪ 10:33, 30 January 2014 (UTC)
See Module:ConvertNumeric for the last word in spelling numbers! (It is used by Module:Convert, but the name is coincidental as it was created by Dcoetzee.) One factor about require is that if a module always requires something, that something has to be available, even if unused. I wanted Module:Convert to be easily usable at other wikis, and the spelling only works in English and is rarely used, so Convert only requires ConvertNumeric if needed, and it fails gracefully if it is not present (in that case, the results are displayed with digits and are not spelled). The module is ultra complex so I'll mention that anyone wanting to see the relevant code should search for the spell_number function which requires ConvertNumeric the first time the function is called.
Scribunto is very fast, so the overhead of requiring an unused module is probably not a problem, particularly when the module is small. However, Lua will methodically convert the entire required module to code for each template that invokes Module:TimeAgo (ten times if the template occurs ten times on a page), and it is irritating to repeat such work when unnecessary.
Another factor is that Special:WhatLinksHere/Module:NumberSpell is not helpful as it shows all pages where the module is required, whereas presumably it is only used on a small fraction of those pages.
On balance, I would be inclined to have something like this:
local numberSpell (near the top of the module)
numberSpell = numberSpell or require('Module:NumberSpell')._main (just before use)
Then the module is only required if used. Perhaps for TimeAgo, you know that numberSpell will only be called once, so the "numberSpell or" is not needed. OTOH, if it is only called once, you could do this:
result_num_text = require('Module:NumberSpell')._main( result_num )
Johnuniq (talk) 11:19, 30 January 2014 (UTC)

Outputting only the number or unit

Currently, it's possible to suppress the word "ago". Would it be feasible to add an option to suppress either the number or the unit (thereby outputting only the other)? For example, if the duration is 15 hours, it would be possible to output either "15" or "hours"/"hours ago" on its own. —David Levy 21:20, 4 June 2014 (UTC)

Case sensitive

Hi - If there is a change in case, can a note be added to the main Template page? (As I don't expect 104,000 pages to be notified of the change.) When I went to WP:FIX today, a 'time ago' on December 27, 2014 was listed as 22 hours ago today. Changing all 'time ago' to 'Time ago' corrected the problem. Thank you! Sct72 (talk) 21:15, 24 January 2015 (UTC)

@Sct72: Template names, like article names, are always case-insensitive for the first letter: there is no difference in effect between {{time ago}} and {{Time ago}}. This template, like all of the date/time calculation templates, does not update calculated values automatically: an edit to the page is required. The nature of the edit is immaterial: any edit will work, even a null edit. Making alterations like these may appear to "fix" the problem, but none were necessary. Have a look at the page this time tomorrow: you'll see that it appears to be out of date by approximately 24 hours - unless somebody else has edited the page in the meantime. --Redrose64 (talk) 21:31, 24 January 2015 (UTC)
@Redrose64:Either the issue is corrected, or there's a larger issue that needs to be fixed. I guess we will find out. But for now, December 27, 2014 is showing the correct 28 days ago on WP:FIX. Sct72 (talk) 22:41, 24 January 2015 (UTC)
You misunderstand. The very act of editing the page causes all the calculations to be redone. If there is no edit, there is no recalculation. This is why you occasionally see biographical articles which show the "wrong" age in the infobox: the age is calculated by {{birth date and age}}, which has nothing special to update it - it relies on the page being edited on (or fairly soon after) the person's birthday in order for the age to be updated - simply viewing the page is not enough. This is why you sometimes see IPs making edits like this which (even if they don't break the layout in so doing) are unproductive. A simple WP:NULLEDIT (or perhaps even a WP:PURGE, which causes less server load) would have done the job - but some sort of action is necessary, the page won't update on its own; there is no means to make an automatically-updated value. The underlying code of {{time ago}} and {{birth date and age}} do basically the same job: they subtract some moment in the past from the current time to give an elapsed time.
For small numbers of pages that need to have these elapsed times recalculated on a frequent basis (such as categorising the articles in these dated cats into Category:Expired proposed deletions after seven days), we have Joe's Null Bot (talk · contribs), which simply makes a WP:NULLEDIT and in so doing forces all templates to be reparsed and all categories to be redetermined; but I don't think that Joe Decker (talk · contribs) would be willing to run it on over 100,000 pages on a daily basis for evermore. --Redrose64 (talk) 23:13, 24 January 2015 (UTC)
I have updated WP:FIX with a note on updating the Time Ago column. Thank you for the information. Sct72 (talk) 21:17, 31 January 2015 (UTC)
I have simplified your note with {{Purge}}.[1] PrimeHunter (talk) 22:35, 31 January 2015 (UTC)
Yeah, Null Bot can't scale to that problem, not a matter of equipment, just the wrong solution for that big a problem. --j⚛e deckertalk 04:05, 4 February 2015 (UTC)

Is there as way to input an interval + current date = displayed date?

In other words: Can you display a year that is always 17 years ago, so updates like this are no longer necessary? Sorry if already covered or I'm missing something. --RacerX11 Talk to meStalk me 00:21, 8 May 2015 (UTC)

{{#expr:{{CURRENTYEAR}}-17}} produces 2007. See mw:Help:Extension:ParserFunctions##time for a more advanced function. PrimeHunter (talk) 00:33, 8 May 2015 (UTC)
Thank you very much! --RacerX11 Talk to meStalk me 00:36, 8 May 2015 (UTC)
{{#time:Y|now-17years}} produces 2007. For comparison, less typing. –Be..anyone (talk) 19:42, 26 May 2015 (UTC)

Yesterday, Today, and Tomorrow

Hello! Can someone more familiar with Lua than I make the appropriate modifications to have the module return a relative day in the following situations:

  • 1 day ago → Yesterday
  • 0 days ago → Today
  • 0 days ago → Tomorrow
  • 0 days' time → Tomorrow

Thanks! — {{U|Technical 13}} (etc) 15:33, 12 December 2014 (UTC)

I agree this would be a nice feature, although of course 12 hours ahead is not always going to be tomorrow, and 36 hours ahead might be two days into the future. — Martin (MSGJ · talk) 10:18, 9 July 2015 (UTC)

Permit null argument for ago keyword

In some cases, a sentence will end with a time period. For instance, the template may help construct the phrase "where he has worked for the past 20 years." A recent coding change has made it impossible to nullify the "ago" argument, causing a space to be inserted after the units. Without the option of a null value, we are relegated to either rewording the sentence, or accepting a space between the units and the punctuation. As an example, coding "ago=." will yield "where he has worked for the past 20 years ." Can the forced space before the "ago" variable be omitted when the keyword has a null value?Antarctic96 (talk) 23:49, 12 January 2014 (UTC)

I've done it, so now the code He has worked for FooBar Corp for the last {{time ago|1 January 1985|ago=}}. will produce "He has worked for FooBar Corp for the last 39 years." Let me know if you notice any other discrepancies between the old version of the template and the new Lua version. Best — Mr. Stradivarius ♪ talk ♪ 05:15, 13 January 2014 (UTC)
Mr. Stradivarius: could the same or additional parameter be used to suppress the "' time" output for future times? For example, in a table with column heading "expires" is it obvious enough just to use "2 years" rather than "2 years' time". Thanks in advance — Martin (MSGJ · talk) 10:18, 9 July 2015 (UTC)
@MSGJ: Ok, it's up live, using the blank "ago" parameter syntax. — Mr. Stradivarius ♪ talk ♪ 14:17, 9 July 2015 (UTC)

Template-protected edit request on 26 March 2018

Lines 16 and 27 of the module create globals, that cause errors with Module:No globals. Please add local to the beginning of each of these two lines. Luis150902 (talk | contribs) 22:16, 26 March 2018 (UTC)

Thanks, I did that. Johnuniq (talk) 00:34, 27 March 2018 (UTC)

Sawiki error

Line 56 of the module giving error in sawiki. Maybe it's because of the no. conversion. Can someone please help? Capankajsmilyo (talk) 04:56, 2 April 2018 (UTC)

As at Module talk:WikidataIB#Trying to use on sawiki, please provide a link to a page demonstrating the problem. Did you try the {{formatnumber:input|R}} solution you found? By the way, test modules should be under Module:Sandbox, see Special:PrefixIndex/Module:Sandbox. Johnuniq (talk) 05:10, 2 April 2018 (UTC)
PS. sa:Template:Time ago for the error which is "लुआ त्रुटि पटलम्:TimeAgo में पंक्ति 56 पर: attempt to perform arithmetic on a string value।". Capankajsmilyo (talk) 06:48, 2 April 2018 (UTC)
Further {{formatnumber}} is for templates. How can we use them in module? Capankajsmilyo (talk) 06:49, 2 April 2018 (UTC)
I just edited sa:Module:TimeAgo to insert "xn" which I found at mw:Help:Extension:ParserFunctions##time. Apparently, using "U" gets the Unix time in local digits, whereas "xnU" gets it in English digits. The enwiki module should probably use "xnU" to make it easier for other Wikipedias. When I mentioned formatnumber I was imagining the problem must concern input to the module. Johnuniq (talk) 07:48, 2 April 2018 (UTC)
Thanks a lot Johnuniq. I too request enwiki module editors to please make changes as suggested by Johnuniq. Capankajsmilyo (talk) 08:27, 2 April 2018 (UTC)

@Mr. Stradivarius: Please see my edit at sawiki: diff. You might like to contemplate that (see "xnU" above with link to doc) and put it in Module:TimeAgo at enwiki. Johnuniq (talk) 09:14, 2 April 2018 (UTC)

How to remove time unit?

I need to remove the time unit for the table on List of most-subscribed YouTube channels. How do I do that? Ping me if you reply. —Wei4Green | 唯绿远大 (talk) 23:16, 2 April 2019 (UTC)

'purge'

'Update timer' would be a lot clearer to non-technical folks. Headbomb {t · c · p · b} 20:30, 20 August 2018 (UTC)

I agree. —Wei4Green | 唯绿远大 (talk) 23:47, 2 April 2019 (UTC)

Requested move 30 October 2019

The following is a closed discussion of a requested move. Please do not modify it. Subsequent comments should be made in a new section on the talk page. Editors desiring to contest the closing decision should consider a move review after discussing it on the closer's talk page. No further edits should be made to this discussion.

The result of the move request was: Moved (closed by non-admin page mover) Wug·a·po·des04:58, 8 November 2019 (UTC)


– Match name with template. * Pppery * it has begun... 22:09, 30 October 2019 (UTC)

Why did people keep CamelCasing the titles of modules they created to implement templates with spaced out titles. * Pppery * it has begun... 22:09, 30 October 2019 (UTC)

The above discussion is preserved as an archive of a requested move. Please do not modify it. Subsequent comments should be made in a new section on this talk page or in a move review. No further edits should be made to this section.

PLURAL support

It would be great if this module allowed the use of the plural magic word. Please see this thread about how it was implemented for Module:Age. – Srđan (talk) 17:36, 21 April 2021 (UTC)

Apparent bug in "weeks" calculation when input is YYYYMMDDHHIISS with hour=0 and minute=0

Please see the test cases page for a demonstration of an apparent bug in the "weeks" output when the input time format is YYYYMMDDHHIISS and both the hour and minute values are 00. My gut feeling is that the bug, if it is a bug, is in the module code if input.hour == 0 and input.minute == 0 then. – Jonesey95 (talk) 17:56, 1 February 2022 (UTC)

@Jonesey95: I'm starting with some links as self-reminders. This started at VPT and you added some new testcases, which need familiarity with the #time documentation. I tried to make a simple test so I could examine what's going on but after struggling with #time I don't understand the new tests. Is 521 correct? 521 hours = 21 days 17 hours which #time is rounding to 22 days for Ymd format.
The numbers in the two tests marked as having erroneous outputs gave these results when I previewed a sandbox edit an hour or two ago.
  • {{#time:YmdHis}} → 20220202041747
  • {{#time:Ymd|@{{#expr:({{#time:U}} - 521*60*60) }}}}000030 → 20220111000030
  • {{#time:Ymd|@{{#expr:({{#time:U}} - 1193*60*60) }}}}000030 → 20211214000030
I am confident that the following template gives correct results. It is showing the time difference that {{time ago}} would have determined when I did the test above. This shows that the results (3 weeks ago and 7 weeks ago) are correct.
  • {{time interval|2022-01-11 00:00:30|2022-02-02 04:17:47|show=dhms}} → 22 days, 4 hours, 17 minutes and 17 seconds
  • {{time interval|2021-12-14 00:00:30|2022-02-02 04:17:47|show=dhms}} → 50 days, 4 hours, 17 minutes and 17 seconds
On the other hand, I believe you are correct about the 30-second difference being a problem. I tried another method to generate the problem, as below. I'm not suggesting to use this in the testcases—I'm just working with something I'm more familiar with. Today (20220202) the {{extract}} stuff generates 20220112 which is 21 days ago.
  • {{Time ago|{{extract|currentdate|add=-21d|show=%Y%m%d}}000000|magnitude=weeks}} → 3 weeks ago
  • {{Time ago|{{extract|currentdate|add=-21d|show=%Y%m%d}}000030|magnitude=weeks}} → 2 weeks ago
Johnuniq (talk) 06:18, 2 February 2022 (UTC)

Oops, I had forgotten but now see that I edited Module:Time ago/sandbox in April 2019. Also, I see that the module uses Module:Date for the time difference so that's my problem. Meanwhile, I have added parameter now to the sandbox module so {{time ago/sandbox}} can use a specified date/time instead of the current date/time. The value is the wanted Unix time (seconds since the start of 1 January 1970). That can be found from {{#time:xnU}} (which is the same as {{#time:U}} except that U gives non-English digits at some other languages, while xnU always gives a plain English number) any time/date text that is accepted by both #time and Module:Date.

The following should be showing a time difference of exactly 14 days.

  • {{time ago/sandbox|20220101000000|now=2022-01-15 00:00:00|magnitude=hours}} → 336 hours ago
  • {{time ago/sandbox|20220101000000|now=2022-01-15 00:00:00|magnitude=days}} → 14 days ago
  • {{time ago/sandbox|20220101000000|now=2022-01-15 00:00:00|magnitude=weeks}} → 2 weeks ago

Module:Date knows the correct number of weeks as shown by:

  • {{time interval|2022-01-01 00:00:00|2022-01-15 00:00:00|show=w}} → 2 weeks

I'll examine what's going on but that might not be for a day or two. Johnuniq (talk) 08:39, 2 February 2022 (UTC)

Update: The crazy result above (it was showing "4 weeks ago" instead of 2) is due to my quick addition of parameter now being faulty. For some reason, the module refers to the input twice but I only inserted now for the first occurrence where it didn't achieve anything. More time needed. Johnuniq (talk) 09:15, 3 February 2022 (UTC)
I have fixed Module:Time ago/sandbox so args.now works correctly and the test above works. Now I'll think about what the actual problem is. Johnuniq (talk) 02:39, 4 February 2022 (UTC)

Here is what the module does with the two testcases flagged as "erroneous". This shows the results that would have occurred at the "now" time (2022-02-02 04:17:47). These results look good to me.

  • {{time ago/sandbox|2022-01-11 00:00:30|now=2022-02-02 04:17:47|magnitude=weeks}} → 3 weeks ago
  • {{time ago/sandbox|2021-12-14 00:00:30|now=2022-02-02 04:17:47|magnitude=weeks}} → 7 weeks ago

Johnuniq (talk) 04:22, 4 February 2022 (UTC)

Requesting error-tracking category

This template currently generates Error: first parameter cannot be parsed as a date or time. when there is an error, but pages are not tracked in a category so that they can be fixed. Can someone please add Category:Pages using Time ago template with errors or something similar, probably wrapped in {{Main other}}, so that these errors can be tracked? The error message is currently visible at Comparison of issue-tracking systems. – Jonesey95 (talk) 15:35, 12 January 2023 (UTC)