Module talk:Age: Difference between revisions

Content deleted Content added
abbr=on violates MOS: Responded to edit request
m Archiving 2 discussion(s) to Module talk:Age/Archive 1) (bot
 
(32 intermediate revisions by 10 users not shown)
Line 1:
{{talk header}}
{{Permanently protected}}
{{User:MiszaBot/config
 
| algo = old(180d)
==Module:Age==
| archive = Module talk:Age/Archive %(counter)d
I created [[Module:Age]] to fix some problems reported with {{tl|Age in years and months}}, and that template has been replaced with code to invoke this module. I don't know if it would be worth replacing other related templates with a call to a module, but as an experiment I have added code to this module to implement {{tl|Age in days}} and {{tl|Gregorian serial date}}. I have done over 100 tests offline which suggest that the module is performing correctly. The following shows a few results that compare the outputs from the current templates with [[User:Johnuniq/age days]] and [[User:Johnuniq/gsd]] which invoke the module.
| counter = 1
 
| maxarchivesize = 150K
{| class="wikitable" style="text-align: center;"
| archiveheader = {{Talk archive navigation}}
! Parameters to template !! Result from <code><nowiki>{{age in days}}</nowiki></code> !! Result from <code><nowiki>{{User:Johnuniq/age days}}</nowiki></code>
| minthreadstoarchive = 2
|-
| minthreadsleft = 4
| <code><nowiki>&#124;1898&#124;1&#124;1&#124;1900&#124;1&#124;1</nowiki></code> || {{age in days|1898|1|1|1900|1|1}} || {{User:Johnuniq/age days|1898|1|1|1900|1|1}}
}}
|-
| <code><nowiki>&#124;1900&#124;1&#124;1&#124;1898&#124;1&#124;1</nowiki></code> || {{age in days|1900|1|1|1898|1|1}} || {{User:Johnuniq/age days|1900|1|1|1898|1|1}}
|-
| <code><nowiki>&#124;2013&#124;4&#124;1</nowiki></code> || {{age in days|2013|4|1}} || {{User:Johnuniq/age days|2013|4|1}}
|}
 
{| class="wikitable" style="text-align: center;"
! Parameters to template !! Result from <code><nowiki>{{gsd}}</nowiki></code> !! Result from <code><nowiki>{{User:Johnuniq/gsd}}</nowiki></code>
|-
| <code><nowiki>&#124;year=1&#124;month=1&#124;day=1</nowiki></code> || {{gsd|year=1|month=1|day=1}} || {{User:Johnuniq/gsd|year=1|month=1|day=1}}
|-
| <code><nowiki>&#124;year=2000&#124;month=12&#124;day=31</nowiki></code> || {{gsd|year=2000|month=12|day=31}} || {{User:Johnuniq/gsd|year=2000|month=12|day=31}}
|-
| <code><nowiki>(none)</nowiki></code> || {{gsd}} || {{User:Johnuniq/gsd}}
|}
 
I'll mention this in a couple of places to let people know the module is available. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:55, 2 April 2013 (UTC)
:Seems to be working well! Will it also work in ''e''.''g''. {{tl|Birth date and age}}? '''[[User:It Is Me Here|<span style="color:#006600">It Is Me Here</span>]]''' <sup>'''[[User_talk:It Is Me Here|<span style="color:#CC6600">t</span>]] / [[Special:Contributions/It Is Me Here|<span style="color:#CC6600">c</span>]]'''</sup> 14:55, 11 June 2013 (UTC)
::I'm super busy and can't take on any extra thinking for a while, however the short answer is that the module could fairly easily be extended to handle what I think the birth date and age template is doing, but it would need a bit of work and testing. Is there a known problem with the template? If so, that would focus my attention and make it more likely that people would want to accept a new solution to the very widely used dob template. It's a bit lucky that I noticed this. If you post here and I don't reply in a day or two, please ping my talk. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:42, 12 June 2013 (UTC)
:::No problems as such that I know of; it's just that I thought that templates using Modules rather than template code loaded faster (esp. on mobile devices)? There's no rush; I just thought that if the bulk of the work has already been done, and that it would be a relatively easy matter to employ this code in other areas, it would seem a shame not to if it improves reader experience. '''[[User:It Is Me Here|<span style="color:#006600">It Is Me Here</span>]]''' <sup>'''[[User_talk:It Is Me Here|<span style="color:#CC6600">t</span>]] / [[Special:Contributions/It Is Me Here|<span style="color:#CC6600">c</span>]]'''</sup> 10:54, 13 June 2013 (UTC)
 
== Recent change ==
 
I just reverted the change to the module as it broke the module, adding over a hundred articles to [[:Category:Pages with script errors]]. One change that broke things was the removal of age_ym but there was possibly others, I did not even try checking all the articles with errors but looked for the recent change that caused it.--<small>[[User:JohnBlackburne|JohnBlackburne]]</small><sup>[[User_talk:JohnBlackburne|words]]</sup><sub style="margin-left:-2.0ex;">[[Special:Contributions/JohnBlackburne|deeds]]</sub> 12:24, 24 June 2016 (UTC)
:@[[User:JohnBlackburne|JohnBlackburne]]: Thanks! Unfortunately there was a lot of off-wiki chaos here yesterday and I completely forgot to update {{tl|age in years and months}} for the way the new module works. I did check a few things before I was called away, but the pages hadn't updated so I didn't see any problems. I have restored the new version and updated the template, and will be monitoring the situation. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:01, 25 June 2016 (UTC)
 
== Allow julianday month offsets to permit use in JULIANDAY ==
 
<!--{{Edit template-protected|answered=yes}}-->
'''<s>{{tl|Edit template-protected}}</s> closed by author'''
 
{{tl|JULIANDAY}} is the only template listed in [[Module:Age/doc#Templates supported|the docs]] that doesn't use this module, and I believe it's because of edge cases involving leap years and too-large day-of-months in general, which the Age module rejects but the JULIANDAY template accepts. "1900-02-29" doesn't make sense in most other contexts, but it has a well-defined Julian day and is expected to work in the current {{tl|JULIANDAY}} template (see [[Template:JULIANDAY/testcases|testcases]]).
 
The edit I'm requesting fixes this compatibility issue by using an offset, and if it is accepted we should be able to finally replace {{tl|JULIANDAY}} with this module so that all implemented template functionalities in the docs are actually used in their corresponding templates.
 
This edit only affects the <code>dateToJd</code> function, so it will not affect any non-Julian-day usage of the module. It's fully implemented in [[Module:Age/sandbox|the module sandbox]] and it's been tested with all the {{tl|JULIANDAY}} testcases. Here's the revised function:
 
<pre>
local function dateToJd(frame)
-- Return Julian date (a number) from a date which may include a time,
-- or the current date ('currentdate') or current date and time ('currentdatetime').
-- The word 'Julian' is accepted for the Julian calendar.
local Date = getExports(frame)
local args = frame:getParent().args
local date
if args[1] and args[2] then
date = Date(args[1], args[2], 1, args[4], args[5], args[6], args[7])
elseif args[1] then
date = Date(args[1], 1, 1, args[4], args[5], args[6], args[7])
else
date = Date(args[1], args[2], args[3], args[4], args[5], args[6], args[7])
end
local offset = 0
if args[3] then
offset = tonumber(args[3]) - 1
end
if date then
return tostring(date.jd + offset)
end
return message('Need valid year/month/day or "currentdate"')
end
</pre>
 
I can of course make any other changes if they help. Thanks, [[User:Habst|Habst]] ([[User talk:Habst|talk]]) 05:12, 17 June 2018 (UTC)
:Please let's take some time to discuss this before moving to change the module. The only reason I haven't yet updated {{tl|JULIANDAY}} to use the module is that I got distracted by other things. I updated the templates very slowly because the tracking categories can take a long time to catch up and show any problems, and I'm conservative about changing code. It also took quite a lot of work to fix old errors (invalid dates) in articles that the module reported.<p>Thorough tests show that the module gives correct Julian days for all dates from 9999 BCE to 9999 CE (I wrote a test harness to check the first and last days of the month for all years in that range). The current template uses arithmetic that fails for dates well inside that range. For example, <code><nowiki>{{JULIANDAY|-4800|3|1}}</nowiki></code> (using the old template) gives -32410 whereas the module gives -32044. A reasonable argument could be made that it is silly to expect a Julian day for such an extreme date, but that's how it is. I will need 24 hours to think about the above. Meanwhile, the major advantage of the module IMHO is that it displays an error if an invalid date is used. Why would anyone want to know the Julian day of 1900-02-29 or 2018-04-31 (both of which are invalid dates)? [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:49, 17 June 2018 (UTC)</p>
:By the way, the module supports <code>fix=on</code> which allow invalid dates to be entered. The date is adjusted by overflowing the day/month values. For example, using {{tl|extract}}:
:*<code><nowiki>{{JULIANDAY|1900|02|28}}</nowiki></code> → {{JULIANDAY|1900|02|28}}
:*<code><nowiki>{{extract|1900-02-28|show=juliandate}}</nowiki></code> → {{extract|1900-02-28|show=juliandate}}
:*<code><nowiki>{{extract|1900-02-29|fix=on|show=juliandate}}</nowiki></code> → {{extract|1900-02-29|fix=on|show=juliandate}}
:If <code>fix=on</code> were omitted, the last of the above would show an error. If there was a reason for needing it, that parameter could be made available in {{tl|JULIANDAY}}. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:57, 17 June 2018 (UTC)
:: Hi {{u|Johnuniq}}, thanks for your points here and I agree we should discuss it. I have no problem using the current <code>dateToJd</code> function in {{tl|JULIANDAY}} if that is acceptable -- the only reason why I modified the function to accept invalid dates were because invalid dates were being used in the test cases (which I didn't write) so I wanted to make them pass.
:: I agree that the Lua module is more accurate for larger magnitude dates, and I think that's a good reason to begin to use the module in the template (surely nobody would have depended on that incorrect behavior with the template arithmetic). Maybe using <code>fix=on</code> is better than my offset change -- if it is, then we should use that instead. Or if nobody cares about knowing the date of 1900-02-29, then maybe we shouldn't use it at all. What do you think? --[[User:Habst|Habst]] ([[User talk:Habst|talk]]) 19:57, 17 June 2018 (UTC)
:::I would far prefer to have the template require valid dates and fix problems found where invalid dates are used. That is much better in the long run than accepting junk. I revert a dozen vandal attacks on articles each week when the bad edit damages a date in a template monitored by this module's error tracking category. Do you know of any reason to accept invalid or partial dates for JULIANDAY other than some test examples? I'll look at some examples of JULIANDAY in articles later. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:31, 17 June 2018 (UTC)
::::I don't know of any examples; I only did it because of the testcases. If it's not used in practice and not documented, then there would be no harm in making the switch to the module either way. Do you think I should cancel this ER and make one at the {{tl|JULIANDAY}} template to just use the unmodified module then? --[[User:Habst|Habst]] ([[User talk:Habst|talk]]) 23:43, 17 June 2018 (UTC)
:::::I'll update JULIANDAY soon but I need to check my notes on the usage of that template first to gauge how many problems might occur. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 01:21, 18 June 2018 (UTC)
::::::I updated {{tl|JULIANDAY}} to use [[Module:Age]]. It turns out the template was used in only half a dozen articles, but is used in about 20 templates which are used in around 12,000 articles. It is too hard to determine whether those templates can generate an invalid date, but a few cases that I checked only had valid dates. I will monitor [[:Category:Age error]] to see if errors are reported. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:56, 18 June 2018 (UTC)
::::::: OK, thank you! I'm marking this as resolved now. --[[User:Habst|Habst]] ([[User talk:Habst|talk]]) 05:20, 18 June 2018 (UTC)
::::::::I had to revert my edit so JULIANDAY is again using the old template code. Using the module there were hundreds of articles in [[:Category:ParserFunction errors]] due to a handful of templates that I will investigate later: {{tl|update after}} + {{tl|show by date}} + {{tl|PD-Australia}} and possibly others. That will be due to errors reported by the module with invalid dates but I'll check what's going on and do something in a day or two. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 06:09, 18 June 2018 (UTC)
The problem is that templates like {{tl|update after}} can pass expressions in a parameter, such as <code>18+0</code> for the day. That works with the old template because everything is wrapped in a #expr and so is evaluated. The module would have to use <code>mw.ext.ParserFunctions.expr</code> on each parameter if it's not a number. Problem: the module supports single-parameter dates, for example, these are the same (there is no comma for the first case since some templates expect a value without commas when used like this):
*<code><nowiki>{{age in days|2001|5|23|2011|6|1}}</nowiki></code> → {{age in days|2001|5|23|2011|6|1}}
*<code><nowiki>{{age in days|May 23, 2001|1 June 2011}}</nowiki></code> → {{age in days|May 23, 2001|1 June 2011}}
I'll need a while to think about whether that can be supported for JULIANDAY while evaluating non-numbers as an expression. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:52, 18 June 2018 (UTC)
 
Hmm, I tried something and will think about it later:
*<code><nowiki>{{JULIANDAY|2012|4|30}}</nowiki></code> → {{JULIANDAY|2012|4|30}}
*<code><nowiki>{{JULIANDAY/sandbox|April 30, 2012}}</nowiki></code> → {{JULIANDAY/sandbox|April 30, 2012}}
*<code><nowiki>{{JULIANDAY/sandbox|2012|4|30}}</nowiki></code> → {{JULIANDAY/sandbox|2012|4|30}}
*<code><nowiki>{{JULIANDAY/sandbox| 2000 + 12 |12-9+1|3*10+0}}</nowiki></code> → {{JULIANDAY/sandbox| 2000 + 12 |12-9+1|3*10+0}}
[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:15, 18 June 2018 (UTC)
:{{tl|Show by}} mentions relative (e.g. +20 hours) times. The module can add/subtract date/time units but matching the syntax supported by #expr would be tricky. I'm starting to think there is no point in having the module implement JULIANDAY, apart from the fact that the module gives accurate results for weird dates that are unlikely to be used. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:10, 20 June 2018 (UTC)
:: Thanks for your research on this {{u|Johnuniq}}. Why not have the template be a wrapper around the module that just <code>#expr</code>s all its arguments first before passing them to the age module? --[[User:Habst|Habst]] ([[User talk:Habst|talk]]) 07:01, 20 June 2018 (UTC)
:::The templates supported by the module allow entry of a date in various formats, for example <code>|2012|4|30</code> or <code>|2012-4-30</code> or <code>30&nbsp;Apr&nbsp;2012</code> or <code>April&nbsp;30,&nbsp;2012</code>. The time can also be included in each of these formats. The last example at 10:15, 18 June 2018 just above shows that the sandbox handles simple expressions—it tests each parameter to avoid trying to evaluate something like <code>|2012-4-30</code>. A problem is that it is not clear how JULIANDAY is being used—I haven't seen any examples of "+20 hours" in the docs mentioned just above, so I'm not sure what needs to be supported. One approach would be to switch the template to use the module again and see what breaks to determine what fixes would be needed in addition to what the sandbox does now. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:21, 20 June 2018 (UTC)
 
== Age/birth/death templates ==
 
The following templates are not implemented by [[Module:Age]]. They do not emit metadata.
{| class="wikitable"
! Template !! Usage
|-
| {{tl|age as of date}} || articles
|-
| {{tl|birth based on age as of date}} || articles
|-
| {{tl|birth date based on age at death}}|| articles
|-
| {{tl|birth year and age}} || articles
|-
| {{tl|birthDeathAge}} || articles
|-
| {{tl|death year and age}} || articles
|-
| {{tl|years ago}} || articles
|-
| {{tl|years or months ago}} || articles
|-
| {{tl|birth year from age at date}} || redirect to {{tl|birth based on age as of date}}
|-
| {{tl|age in days ymd}} || unused
|-
| {{tl|age in years, months, weeks, days and hours}}|| unused
|-
| {{tl|age ymd}} || unused
|-
| {{tl|age in fortnights}} || used in a userbox
|-
| {{tl|age2}} || used in two articles; partial dates
|-
| {{tl|age in decimal years}} || used in one article
|-
| {{tl|age in sols}} || used in some Mars articles
|}
 
The following templates are used in articles and emit metadata.
{| class="wikitable"
! Template !! In [[Module:Age]]
|-
| {{tl|birth date and age}} || yes
|-
| {{tl|birth date and age2}} || –
|-
| {{tl|birth date}} || –
|-
| {{tl|birth-date and age}} || –
|-
| {{tl|birth-date}} || –
|-
| {{tl|death date and age}} || yes
|-
| {{tl|death date and given age}} || –
|-
| {{tl|death date}} || –
|-
| {{tl|death-date}} || redirect to {{tl|end-date}}
|-
| {{tl|death-date and age}} || –
|-
| {{tl|end-date}} || –
|}
 
Examples showing the metadata emitted by the above templates.
<pre>
#1 {{birth date|2000|2|10}}
<span style="display:none">(<span class="bday">2000-02-10</span>)</span>February 10, 2000
 
#2 {{birth date and age|2000|2|10}}
<span style="display:none"> (<span class="bday">2000-02-10</span>) </span>February 10, 2000<span class="noprint ForceAgeToShow"> (age&amp;nbsp;16)</span>
 
#3 {{birth date and age2|2012|2|23|2000|2|10}}
<span style="display:none"> (<span class="bday">2000-02-10</span>)</span>February 10, 2000 (aged 12)
 
#4 {{birth-date|10 February 2000}}
<span class="mw-formatted-date" title="2000-02-10">10 February 2000</span><span style="display:none">&amp;#160;(<span class="dtstart bday">2000-02-10</span>)</span>
 
#5 {{birth-date|February 2000}}
February 2000<span style="display:none">&amp;#160;(<span class="dtstart bday">2000-02</span>)</span>
 
#6 {{birth-date|2000}}
2000<span style="display:none">&amp;#160;(<span class="dtstart bday">2000</span>)</span>
 
#7 {{birth-date and age|2000}}
2000<span style="display:none">&amp;#160;(<span class="dtstart bday">2000</span>)</span> (age&amp;nbsp;<span class="currentage"></span>19)
 
#8 {{birth-date and age|2000|2}}
2<span style="display:none">&amp;#160;(<span class="dtstart bday">2000</span>)</span> (age&amp;nbsp;<span class="currentage"></span>19)
 
#9 {{death date|2012|2|23}}
<span style="display:none">(<span class="dday deathdate">2012-02-23</span>)</span>February 23, 2012
 
#10 {{death date and given age|2012|2|23|45}}
<time class="dday deathdate" datetime="2012-02-23">February 23, 2012</time> (aged&amp;nbsp;45)
 
#11 {{death-date|23 February 2012}}
<span class="mw-formatted-date" title="2012-02-23">23 February 2012</span><span style="display:none">&amp;#160;(<span class="dtend ">2012-02-24</span>)</span>
 
#12 {{death-date|February 2012}}
February 2012<span style="display:none">&amp;#160;(<span class="dtend ">2012-03</span>)</span>
 
#13 {{death-date|2012}}
2012<span style="display:none">&amp;#160;(<span class="dtend ">2013</span>)</span>
 
#14 {{death-date and age|23 Feb 2012|10 Feb 2000}}
<span class="mw-formatted-date" title="2012-02-23">23 Feb 2012</span><span style="display:none">&amp;#160;(<span class="dtend dday deathdate">2012-02-24</span>)</span> (aged&amp;nbsp;12)
 
#15 {{death-date and age|Feb 2012|Feb 2000}}
Feb 2012<span style="display:none">&amp;#160;(<span class="dtend dday deathdate">2012-03</span>)</span> (aged&amp;nbsp;12)
 
#16 {{death-date and age|2012|2000}}
2012<span style="display:none">&amp;#160;(<span class="dtend dday deathdate">2013</span>)</span> (aged&amp;nbsp;12)
 
#17 {{death date and age|2012|2|23|2000|2|10}}
February 23, 2012<span style="display:none">(2012-02-23)</span> (aged&amp;nbsp;12)
 
#18 {{death date and age|2012|2|23|2000|2}}
February 23, 2012<span style="display:none">(2012-02-23)</span> (aged&amp;nbsp;11–12)
 
#19 {{death date and age|2012|2|23|2000}}
February 23, 2012<span style="display:none">(2012-02-23)</span> (aged&amp;nbsp;11–12)
</pre>
[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:11, 12 January 2019 (UTC)
:I asked at [[WT:WikiProject Microformats#Age/birth/death microformats]] which of the above need to be fixed. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:29, 12 January 2019 (UTC)
::Some of those end date templates are outputting a year/month/day after the date entered as a parameter in the metadata. That's because they want the end date to be at the end or after the actual end date (including a time component), so just wondering if it would be better to not include the metadata at all if only the year or month is specified rather than adding on a year or month to the parameter value, and if a full date is specified, rather than adding a day onto that, include the time component in the metadata of 23:59:59 ? -- [[User:WOSlinker|WOSlinker]] ([[User talk:WOSlinker|talk]]) 12:10, 12 January 2019 (UTC)
:::I numbered each template to help identify them. I was wondering why, for example, #12 (February 2012) has metadata 2012-03. You are pointing out that the intention is for the metadata to identify a point in time that is guaranteed to be "the end". If someone died at 23:59 2012-02-29 then 2012-03 would be correct. A standard or local style guide would be nice. I don't really like the bloat in some of the above metadata and would be happier if it was documented as "should" somewhere. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:41, 13 January 2019 (UTC)
:: I would recommend using the <code>time</code> element, if MediaWiki allows that in templates. That's preferable to using <code>display:none</code> to hide metadata. For example, #12 I would author as: <pre><time class="dtend" datetime="2012-02">February 2012</time></pre> While we're at it, I would recommend adding [http://microformats.org/wiki/microformats2 microformats2] class names, so it would become: <pre><time class="dt-end dtend" datetime="2012-02">February 2012</time></pre> I'll review this list of output and comment with other updates. – <span class="h-card">[[User:GregorLove|gRegor]]</span> <small>([[User_talk:GregorLove|talk]]</small> • <small>[[Special:Contributions/GregorLove|contribs]])</small> 01:14, 29 March 2019 (UTC)
 
== Death dates in the future ==
 
I suggest adding [[:Category:Age error]] for death dates more than one day in the future. Allow one day or 15 hours to account for time zones. [//en.wikipedia.org/w/index.php?title=Sydney_Brenner&diff=891013743&oldid=886668043 Example error] (now fixed). [[User:PrimeHunter|PrimeHunter]] ([[User talk:PrimeHunter|talk]]) 20:51, 5 April 2019 (UTC)
:OK, I put that in the sandbox. The following shows what the sandbox produces for someone born on 1 Jan 2000 and who died yesterday, today, tomorrow, the day after tomorrow, and one month in the future.
:*<code><nowiki>{{Death date and age/sandbox|{{extract|currentdate|add=-1d}}|1 Jan 2000}}</nowiki></code> → {{Death date and age/sandbox|{{extract|currentdate|add=-1d}}|1 Jan 2000}}
:*<code><nowiki>{{Death date and age/sandbox|{{extract|currentdate}} |1 Jan 2000}}</nowiki></code> → {{Death date and age/sandbox|{{extract|currentdate}} |1 Jan 2000}}
:*<code><nowiki>{{Death date and age/sandbox|{{extract|currentdate|add=1d}} |1 Jan 2000}}</nowiki></code> → {{Death date and age/sandbox|{{extract|currentdate|add=1d}} |1 Jan 2000}}
:*<code><nowiki>{{Death date and age/sandbox|{{extract|currentdate|add=2d}} |1 Jan 2000}}</nowiki></code> → {{Death date and age/sandbox|{{extract|currentdate|add=2d}} |1 Jan 2000}}
:*<code><nowiki>{{Death date and age/sandbox|{{extract|currentdate|add=1m}} |1 Jan 2000}}</nowiki></code> → {{Death date and age/sandbox|{{extract|currentdate|add=1m}} |1 Jan 2000}}
:<s>What about {{tl|Birth date and age}}? Perhaps birth dates in the future by more than one day should also raise an error? Some articles concern stories unrelated to real people and they could have future birth dates. I suppose showing an error (and the error category) would determine if that was a problem.</s> [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 06:07, 6 April 2019 (UTC)
::Oops, birth date and age already rejects birth dates in the future so this is probably ready for release. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:56, 7 April 2019 (UTC)
:::Done, I updated [[Module:Age]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:47, 7 April 2019 (UTC)
 
== Sorting will use data-sort-value ==
 
I changed [[Module:Age/sandbox]] with a minor enhancement for the <code>|prefix=''text''</code> option and a change to how hidden sort keys work. Once this change is live, all templates implemented by this module (see list at [[Module:Age]]) will use data-sort-value for sort keys. This follows from a [[Template talk:Convert#Switching from hidden sort keys to data-sort-value|discussion]] regarding {{tl|convert}} and {{tl|val}} which will change in a similar manner.
 
The following shows some templates and the output from [[Special:ExpandTemplates]].
<pre>
{{age in days/sandbox|1800-1-1|1800-9-1|prefix=over|sortable=table}}
data-sort-value="7002243000000000000"|over 243
 
{{age in days nts/sandbox|1800-1-1|1800-9-1|prefix=over}}
<span data-sort-value="7002243000000000000♠"></span>over 243
 
{{age in months/sandbox|1800-1-1|1800-9-1|prefix=over|sortable=on}}
<span data-sort-value="7002243000000000000♠"></span>over 8
 
{{time interval/sandbox|1800-1-1|1800-9-1|prefix=over|sortable=on}}
<span data-sort-value="7002243000000000000♠"></span>over 8&amp;nbsp;months
 
{{extract/sandbox|1900-9-1|prefix=before|sortable=on}}
<span data-sort-value="7006241526350000000♠"></span>before 1 September 1900
</pre>
@[[User talk:TheDJ|TheDJ]]: Is the above ok? [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:41, 23 April 2019 (UTC)
 
== Sorting in tables ==
 
A few years ago I saw that Template:age in years and days was being changed to remove the hidden sort key, and the template:ayd or template:age in years and days nts should be used in sortable tables. However, today while editing [[List of longest-living state leaders]], I noticed that when sorting by age, the living leaders all bunched together. When I switched the template to template:age in years and days, this fixed even though if I understand the templates correctly that shouldn't have worked. Has something changed on the back-end or have I misunderstood the template? [[User:Emk9|Emk9]] ([[User talk:Emk9|talk]]) 01:55, 27 April 2019 (UTC)
:The following from [[Special:ExpandTemplates]] shows exactly what the templates output today:
<pre>
{{ayd|1918|5|27}}
&lt;span style="display:none" class="sortkey">7004368600000000000♠&lt;/span>100&nbsp;years, 335&nbsp;days
 
{{age in years and days|1918|5|27}}
100&nbsp;years, 335&nbsp;days
</pre>
:{{tl|ayd}} outputs a hidden sort key before the age, while {{tl|age in years and days}} does not. The reason using the latter appears to be an improvement is that none of the ages for deceased leaders have a sort key, so it works better when the alive leaders also do not have a sort key.
:The correct method would be to use ayd for every entry in the table—that would make all entries sort correctly. Problem: currently the deceased leaders have fixed text for their age. For example, [[Chau Sen Cocsal Chhum]] has "103 years, 143 days". The fix would involve getting the birth and death dates from the article and using them (the dates can use any reasonable syntax):
:*<code><nowiki>{{ayd|1 September 1905|22 January 2009}}</nowiki></code> → {{ayd|1 September 1905|22 January 2009}}
:That would require quite a lot of work. An alternative would involve inserting a manual sort key which needs to be the age expressed in days. This example would be:
:<code><nowiki>{{ntsh|{{#expr:103*365+143}}}}103 years, 143 days</nowiki></code>
:Using 365.25 instead of 365 would be slightly more accurate but probably not worth the trouble. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:00, 27 April 2019 (UTC)
::OK, that makes sense. Thanks [[User:Emk9|Emk9]] ([[User talk:Emk9|talk]]) 05:52, 27 April 2019 (UTC)
 
== Template-protected edit request on 14 September 2019 ==
 
{{edit template-protected|Module:Age|answered=yes}}
There are some good templates for sortable tables:
*{{tl|age in years and days}} -> {{tl|age in years and days nts}}
*{{tl|age in years}} -> {{tl|age in years nts}}
*{{tl|age in days}} -> {{tl|age in days nts}}
Could someone please add this for age in years and months also?
*{{tl|age in years and months}} -> {{tl|age in years and months nts}} [[User:Joseph|Joseph]] ([[User talk:Joseph|talk]]) 09:58, 14 September 2019 (UTC)
::I could think about that but the fact that {{tl|age in years and months nts}} was created less than an hour ago indicates that there has been no need for it in the past. At any rate, the module supports several parameters, one of which controls sorting:
::*<code><nowiki>{{age in years and months|10 Jan 2001|20 Feb 2012}}</nowiki></code> → {{age in years and months|10 Jan 2001|20 Feb 2012}} {{green|1=(normal output, not sortable)}}
::*<code><nowiki>{{age in years and months|10 Jan 2001|20 Feb 2012|sortable=on}}</nowiki></code> → {{age in years and months|10 Jan 2001|20 Feb 2012|sortable=on}} {{green|1=(sortable; use [[Special:ExpandTemplates]] to see the output)}}
::*<code><nowiki>{{age in years and months|10 Jan 2001|20 Feb 2012|sortable=debug}}</nowiki></code> → {{age in years and months|10 Jan 2001|20 Feb 2012|sortable=debug}} {{green|1=(shows the sort key)}}
::That is, a new template is not really needed. This should have started with a discussion, not an edit request, because the latter is used with a "complete and specific description of the request". [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:49, 14 September 2019 (UTC)
* sortable=on works, thanks!.--[[User:Joseph|Joseph]] ([[User talk:Joseph|talk]]) 12:24, 14 September 2019 (UTC)
 
== Localization of time zone for sr.wikipedia ==
 
Could someone help on how to localize this module for sr.wikipedia to Serbian Wikipedia's LOCALDAY i.e. local time in order to have calculation for CET/CEST and not UTC? It is used in birth date and age templates and wrongly calculates age if someone was born just year ago (e.g. displays zero years ago diff at local midnight and at local 1:00 one year ago [when CET and not CEST]) --[[Special:Contributions/5.43.82.5|5.43.82.5]] ([[User talk:5.43.82.5|talk]]) 23:31, 2 March 2020 (UTC)
:Probably not. The module assumes UTC the whole way through and has no localization facility because what it does is already sufficiently complicated; it's just a more accurate and consistent version of the templates that it replaced. However, if you provide a link to a page showing the problem and a brief description of what text on that page is the problem and why, I'll have a look. Are you saying that the servers for srwiki do not use UTC? [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:03, 3 March 2020 (UTC)
::{{ping|Johnuniq}} Thank you for answer. I cannot give you the article page that will ''always'' have wrong output but can give you example that you can test currently or other day near CET midnight ([[:sr:Далибор Илић]]; you can find example for tomorrow's midnight on [[:sr:5. март#Рођења]] and choose any article listed in that* section that has full birth date (mostly recent ones, those lower in the list) *i.e. on Serbian Wiki's day+month article series in Births section. You can test it also with putting current day + 1 and current month with past year as a birth date on [[:sr:Разговор са корисником:5.43.82.5#UTC уместо CET/CEST времена за доб у датуму рођења]] (currently it holds 3 March because I tested it on 2 March night when 3 March was about to come and expected "1 год."** at 3 March CET 00.00 but had "0 год." until 3 March CET 01.00 was the time), or in the sr.wikipedia's sandbox.
::Yes, they do not. Both Belgrade and Banja Luka / Istočno Sarajevo as capitals of most numerous (by Serbian language speaking population) Serbian territories are located in CET/CEST timezone; that is why Serbian Wikipedia has that timezone for all LOCAL? magicwords, which are also used for main page 1-day intervals of changing e.g. featured picture (it changes now at 00.00 CET/CEST and not 01.00 CET or 02.00 CEST i.e. 00.00 UTC). That's why output problem occurs only from 23.00 UTC until 00.00 UTC (there is about [since my signature date] 37 minutes until it starts and 1 hour 37 minutes left until it gets correct output for todays problematic articles, 4 March births which will have for 2000 birth e.g. age displayed 19 and not 20 in the stated problematic period). **Problem is thus left-nsp-spaced bracket text generated by [[:sr:Шаблон:Датум рођења]], text number followed by left-spaced text "год.", both texts smalled in brackets. --[[Special:Contributions/5.43.82.5|5.43.82.5]] ([[User talk:5.43.82.5|talk]]) 22:23, 3 March 2020 (UTC) [e]
::Currently, you can see a problem until 00.00 UTC ("0 год." instead of "1 год."). And when I think more, I conclude that [[:sr:Шаблон:Датум рођења]] should display age asof 12.00 CET/CEST (as well as English [[Template:Birth date and age]] at 12.00 UTC) because we should take into account time of birth which can vary from 00.00 till 23.59 that day, and because we do not know it the most probable (accurate) age guess would be at 12.00 in the time zone needed. --[[Special:Contributions/5.43.82.5|5.43.82.5]] ([[User talk:5.43.82.5|talk]]) 23:11, 3 March 2020 (UTC)
:::I don't have time to examine the situation at the moment, but can you briefly explain why [[:sr:Template:Датум рођења]] has so much wikitext? Google translate tells me it is [[Template:Date of birth]] and I see that it ends up calling Module:Age for the linked article, but why all the template wikitext? Can some adjustment be made there? [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:44, 3 March 2020 (UTC)
::::Because it is questioning many possible cases when only birth month and year e.g. are entered or day and year, etc. It is not [[Template:Date of birth]] but [[Template:Birth date and age]], as already stated. It has incorporated param for yes/no display age (if person is alive / not alive). It calls Age module to calculate age if param "|год=" is yes/no yes, to give age in years ('година' is year in Serbian). I do not see need to simplify working code, expansion depth is not exceeded and it works fine and was tested for all possible combinations (as well as template for death date age which has even more combinations; that's why code is long). --[[Special:Contributions/5.43.82.5|5.43.82.5]] ([[User talk:5.43.82.5|talk]])
{{od|4}}The module has no knowledge of time zones. It is an inherent "feature" of determining an age in years that it will jump by one year as the time passes midnight on the last day of a whole year:
*<code><nowiki>{{age|2019|3|5|2020|3|4}}</nowiki></code> → {{age|2019|3|5|2020|3|4}}
*<code><nowiki>{{age|2019|3|4|2020|3|4}}</nowiki></code> → {{age|2019|3|4|2020|3|4}}
The above is unavoidable. It would be possible to insert a fudge factor so that once an age-in-years was within a certain number of hours before 1 year, that it would display 1 rather than 0.
 
There is no similar problem at enwiki because we use {{tl|birth date and age}} (shown as the redirect {{tl|bda}} below) and it calls [[Module:Age]] which shows ages in the appropriate units (days if less than a month old, months if less than 2 years old, otherwise, years). The following shows some simulated examples using fixed wikitext so it won't change in the future.
*<code><nowiki>{{extract|currentdatetime}}</nowiki></code> → 02:34 4 March 2020 {{green|(date/time when following results occurred)}}
*<code><nowiki>{{bda|df=yes|2020|3|4}}</nowiki></code> → 4 March 2020 (age 0 days)
*<code><nowiki>{{bda|df=yes|2020|3|3}}</nowiki></code> → 3 March 2020 (age 1 day)
*<code><nowiki>{{bda|df=yes|2019|3|5}}</nowiki></code> → 5 March 2019 (age 11 months)
*<code><nowiki>{{bda|df=yes|2019|3|4}}</nowiki></code> → 4 March 2019 (age 12 months)
I think you are saying that the problem at srwiki is that the age jumps forward by a year at UTC midnight when it should advance at CET midnight. I don't think you are going to get a satisfactory fix for that because the displayed text is when the page was last rendered by an edit or [[WP:PURGE]]. Even if the module were fixed, the age would still not roll over at CET midnight because the page showing the age is unlikely to be edited or purged at that time.
 
However, if you want to remove UTC, remove <code>!</code> from the following line in [[:sr:Module:Date]]:
:<code>local d = os.date('!*t')</code>
Doing that would mean the date and age modules get the server local time rather than UTC. That would have the bad side effect of confusing the Julian date calculations which work with UTC but due to the purge lag I mentioned, no one would ever notice. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:49, 4 March 2020 (UTC)
 
:Yes, I say that (it jumps when UTC midnight and not CET/CEST). Thank you for all that extensive info. I don't known what do you mean for Julian but sr.wikipedia does not use it when calculating dates in birth and death date and age templates (always Gregorian date is entered, very simple), so there is no problem with that. Regarding purging, I know it cannot live-update just at midnight but I think when one ''loads'' an article page for first time on a new device with clear cache on it the article page gets refreshed to the last version of the article so it would display indeed wrong time if we do not apply that fix (removing that code in sr:Module:Date). The problem is probably solved now, or at least situation is better if page gets actually purged. That is the information I needed, that one about removing that line that forces UTC; I have just [[:sr:Special:Diff/21261253/22963271|applied it]]. I would like your proposition how to have module age calculating time if end date not entered so current date applied (to make it assume half of the day and not beginning of the day because it is more possibly accurate to reflect current age that way). Thank you once more. --[[Special:Contributions/5.43.82.5|5.43.82.5]] ([[User talk:5.43.82.5|talk]]) 03:20, 4 March 2020 (UTC)
::No, that is not correct about "article page gets refreshed". MediaWiki caches all pages, that is, when an edit or purge occurs, the core of the page is converted to HTML and the HTML is stored in a special server as a cache. When anyone reads the page they see what comes from the cache, slightly modified for their status (e.g. skin if logged in). Here is a test:
::*<code><nowiki>{{#time:Y-m-d H:i:s}}</nowiki></code> → {{#time:Y-m-d H:i:s}}
::My prediction is that editing this page or {{purge|purging it by clicking here}} would update the above timestamp. However, just reading it will not.
::Re your request, I would need a precise example of what you mean.
::By the way, bnwiki localized Module:Age. The method is a bit ugly but it worked well enough for their needs. See [[bn:Module:বয়স]]. They use their equivalent of {{tl|birth date and age}} which calls Module:Age directly without any of the stuff at srwiki (see [[:bn:Template:জন্ম তারিখ ও বয়স]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:07, 4 March 2020 (UTC)
:::OK, that is right. Just clean-loading the page does not refresh everything. Maybe there is auto purge sometimes but never mind, local time should be used anyhow.
:::Explanation is that if one was born on 4 March 2019 and currently is 00.00 4 March 2020 (4 March just began) template {{tl|birth date and age}} does not display (after purge :)) age 1 year but still in months or so, and at 12.00 4 March 2020 (middle of 4 March) that it displays (after purge) age 1 year. My rationale is that because we do not enter birth time in birth date and age template it is wrong to assume that birth time is 00.00 o'clock but mean (middle, of the day – of the birth day, and then reflected into the end date for calculating age).
:::We prefer age in years always and pure code rather than taking care of cases for nouns or using inappropriate unfit or senseless abbreviations of three letters for three letter words (there are 7 cases in Serbian and we do not know how to adjust module to use different cases forms plus displayed text would be long and I mentioned problem with abbreviations). There are clear commentary notes in birth and death date and age templates on sr to easy follow what happens and it is fine-working. --[[Special:Contributions/5.43.82.5|5.43.82.5]] ([[User talk:5.43.82.5|talk]]) 05:47, 4 March 2020 (UTC)
 
== At what point does this module perform its calculations? ==
 
I wonder if anyone could clarify something for me, as either I have a long term misunderstanding of how templates based on this module works, or it is not working correctly. I've looked in the documentation and can't find anything that specifically identifies at what point the calculations occur.
 
If I, for instance, use the [https://en.wikipedia.org/wiki/Template:Age_in_years_and_days_nts age in years and days] template on a page like this; <nowiki>{{ayd|1940|04|16}}</nowiki>, at what point is the calculation for the years and days performed?
 
* At the point I save my edit, and any subsequent edits by others?
* At the point the page is requested/render by a browser?
 
I have always assumed, perhaps incorrectly, that it is the latter. But now it has been pointed out to me that the years/days shown by this template can be significantly out, because no-one has edited the page in some time. This suggests it is the former and my investigations suggest the same.
 
Is this always how it has been? Or something new, or what? Thanks.--[[User:Escape_Orbit|<span style="color: green;">Escape Orbit</span>]] <sup>[[User_talk:Escape_Orbit|(Talk)]]</sup> 17:51, 21 November 2020 (UTC)
:Whenever the page cache for a page is reset/cleared/refreshed/whatever you want to call it, the templates being used on the page will be refreshed. Thus, it is possible that a page calculating a date could be +/- 1, depending on when it was last refreshed. This is how the software works, and there's not really anything that can be done about it. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 19:49, 21 November 2020 (UTC)
::I understand. However, it should be noted that it is not a matter of +/- 1. The difference can be weeks/months. --[[User:Escape_Orbit|<span style="color: green;">Escape Orbit</span>]] <sup>[[User_talk:Escape_Orbit|(Talk)]]</sup> 10:11, 23 November 2020 (UTC)
:::True. Doesn't change the fact that this is a technical limitation based on the way the system caches pages. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 10:32, 23 November 2020 (UTC)
:{{ping|Escape Orbit}} I explained a little more [[Template talk:Age in years, months and days#Help request|here]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:27, 22 November 2020 (UTC)
 
== PLURAL support ==
 
Is it possible for this module to utilize the plural magic word instead of the current plural implementation? This would be useful for localizing the module on wikis where a different form is needed depending on each of the numbers that the module outputs. – [[User:Srđan|Srđan]] ([[User talk:Srđan|talk]]) 07:54, 11 April 2021 (UTC)
:I didn't worry much about localization because there are a lot of quirks that depend on the names of the months, days etc. Making something that properly handled i18n would be difficult and I don't know how much could be implemented using MediaWiki's interfaces. In particular, it is my strong opinion that a date like 1/4/21 should ''not'' be accepted because it is ambiguous in a global encyclopedia but last time I checked the built-in time functions decode it using US rules. When writing [[Module:Convert]] for use at other wikis I found that most people simply wanted a way to prevent the addition of ''s''. Slwiki was very different with seven different possible names for a unit depending on the value. Do you have an example of a language and what it would want to do? [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:53, 11 April 2021 (UTC)
::{{reply to|Johnuniq}} Yeah. For example, all [[Serbo-Croatian]] varieties ([[Bosnian language|Bosnian]], [[Croatian language|Croatian]], [[Serbian language|Serbian]]) and some other Slavic languages use [[:betawiki:Plural/Mediawiki plural rules|"Rule K"]] for plural (see the example column there). So, if I have PLURAL defined as <nowiki>{{PLURAL:$1|mjesec|mjeseca|mjeseci}}</nowiki> for "month", [[:betawiki:MediaWiki:Months/bs|kinda like here]], it should output "mjesec" for 1, 21, 31..., "mjeseca" for 2–4, 22–24, 32–34..., and "mjeseci" for 5–20, 25–30... and so on for the year, week, day, hour, minute and second. – [[User:Srđan|Srđan]] ([[User talk:Srđan|talk]]) 09:05, 12 April 2021 (UTC)
:::Some very rough code below <syntaxhighlight lang="lua">
name = '{{PLURAL:$1|mjesec|mjeseca|mjeseci}}'
text:add(vstr .. sep .. mw.ustring.gsub(name, '%$1', vstr))
</syntaxhighlight> that with some more tweaking might be of use? -- [[User:WOSlinker|WOSlinker]] ([[User talk:WOSlinker|talk]]) 09:55, 12 April 2021 (UTC)
::::{{ping|Srđan}} I see what you mean. I'll have a look at what's involved in a couple of days. Remind me if I haven't posted here within a week (I'll ping you when I post). I gather the aim is to allow easier/better localization of the module for templates like {{tl|age in years and months}}? That would provide a better output in the local language. However this proposal would do nothing for the input to the template which would have to be in English (unless rather heroic edits to the modules were performed). For the input, perhaps some kludge regarding translating local-to-en dates might occur before the module starts processing. I did some work for bnwiki two years ago but have forgotten the details—see a note regarding what they did [[User talk:Johnuniq/Archive 25#Module:Age for bnwiki|here]].{{pb}}@WOSlinker: Thanks but I think the aim is to have PLURAL evaluated (like expanding a template) so that the local MediaWiki would determine using local rules which parameter to use given the numeric value supplied. I'll have to ponder this later. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:02, 12 April 2021 (UTC)
:::::{{ping|Johnuniq}} I've tried it in the sandbox with <nowiki>{{age in weeks and days/sandbox|1946|6|14|1946|8|19}}</nowiki> but the magic word is not being expanded. {{age in weeks and days/sandbox|1946|6|14|1946|8|19}} -- [[User:WOSlinker|WOSlinker]] ([[User talk:WOSlinker|talk]]) 10:05, 12 April 2021 (UTC)
::::::I have to go now so can't look at the moment. There's a Scribunto method for expanding a template and I assume it would work with a magic word. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:11, 12 April 2021 (UTC)
 
::::::: I found this: [[:mw:Extension:Scribunto/Lua_reference_manual#mw.language:convertPlural]] which might be of use. I'm really bad at Lua, so I don't quite know if that's helpful or how to apply it if it is. P.S. Feel free to directly [[:bs:Modul:Age/igralište|edit the sandbox version of the Module at bs.wiki]]. – [[User:Srđan|Srđan]] ([[User talk:Srđan|talk]]) 11:38, 12 April 2021 (UTC)
::::::::{{ping|Srđan}} I've updated [[Module:Age/sandbox]] to use the convertPlural function ([https://en.wikipedia.org/w/index.php?title=Module:Age/sandbox&diff=1017387561&oldid=970777962 changes]) but I'd like Johnuniq to check it before you used it. -- [[User:WOSlinker|WOSlinker]] ([[User talk:WOSlinker|talk]]) 13:54, 12 April 2021 (UTC)
 
::::::::: Awesome. Will plural also work for txt-age and txt-aged? You should also be able to define if it's a prefix or a suffix; [[:bs:Modul:Age#L-805|it's currently a suffix on bs.wiki, for example]]. – [[User:Srđan|Srđan]] ([[User talk:Srđan|talk]]) 15:03, 12 April 2021 (UTC)
:::::::::: Probably but might be more than I could manage. Ages are sometimes a range, so if the range was 4-5 then do you choose "mjeseca" or "mjeseci"? The coding would need to be done to just pass in the first value if it was a range to the plural function. -- [[User:WOSlinker|WOSlinker]] ([[User talk:WOSlinker|talk]]) 17:28, 12 April 2021 (UTC)
::::::::::: You would look at the last item in the range; so in that example, it would be "4–5 mjeseci" (equvivalent to if it were just "5"). Hopefully Johnuniq will take a look at that as well. – [[User:Srđan|Srđan]] ([[User talk:Srđan|talk]]) 18:07, 12 April 2021 (UTC)
::::::::::::I've started seriously looking at this but will need a few days due to off-wiki turbulence. I tried to convince myself that it would be worthwhile to have a special case for English (just add "s" rather than call the language plural function) but it's not. I'll attend to a couple of other issues mentioned above. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:40, 15 April 2021 (UTC)
:::::::::::::Things went faster than expected and I have updated [[Module:Age/sandbox]]. However, I'll need a couple of days to check it. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 10:37, 16 April 2021 (UTC)
I finished work on localizing [[Module:Age/sandbox]] and have requested that it be used to update the main module at bswiki ([[:bs:User talk:Srđan#Module:Age]]) and at bnwiki ([[:bn:User talk:Johnuniq#Module:Age]]). [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:36, 20 April 2021 (UTC)
 
== Add support for Duration in years, months, weeks and days ==
{{Edit template-protected|answered=yes}}
There is currently no way to correctly format the duration between two dates in the same way Age in ... does. There's only [[Template:Duration in days]]. It seems that in many places the Age template is often incorrectly used instead. The change should be fairly trivial by adding the below snippet to https://en.wikipedia.org/wiki/Module:Age#L-703:
 
<pre>
duration_ymwd = { -- {{duration in years, months, weeks and days}}
show = 'ymwd',
duration = true,
},
</pre>
[[User:Phiarc|Phiarc]] ([[User talk:Phiarc|talk]]) 15:29, 11 March 2022 (UTC)
:Confusing – there is no {{tl|Duration in years, months, weeks and days}}. The {{tl|Age}} template is designed only to give the number of years. So what is it exactly that you are proposing? '''''[[User:Paine Ellsworth|<span style="font-size:92%;color:darkblue;font-family:Segoe Script">P.I.&nbsp;Ellsworth</span>]]'''''&numsp;-&nbsp;[[Editor|<span style="color:black">ed.</span>]]&nbsp;[[User talk:Paine Ellsworth|<sup>put'r&nbsp;there</sup>]]&nbsp;<small>20:05, 11 March 2022 (UTC)</small>
::I never got the strength to update the documentation for all the templates that now use [[Module:Age]]. In fact, all the parameters mentioned at the module page can be used.
::*<code><nowiki>{{age in years, months, weeks and days|1 Jan 2001|12 Feb 2002}}</nowiki></code> → {{age in years, months, weeks and days|1 Jan 2001|12 Feb 2002}}
::*<code><nowiki>{{age in years, months, weeks and days|1 Jan 2001|12 Feb 2002|duration=on}}</nowiki></code> → {{age in years, months, weeks and days|1 Jan 2001|12 Feb 2002|duration=on}}
::I don't think it's worth adding more templates when all that's needed is the <code>|duration=on</code> parameter. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 22:35, 11 March 2022 (UTC)
:::Well, you and I could always go fishin' and I could getcha with the first trout I catch. {{p}} '''''[[User:Paine Ellsworth|<span style="font-size:92%;color:darkblue;font-family:Segoe Script">P.I.&nbsp;Ellsworth</span>]]'''''&numsp;-&nbsp;[[Editor|<span style="color:black">ed.</span>]]&nbsp;[[User talk:Paine Ellsworth|<sup>put'r&nbsp;there</sup>]]&nbsp;<small>02:01, 12 March 2022 (UTC)</small>
 
== Something's been broken by using the module rather than the template ==
 
Getting a ParserFunction error. See [[Template talk:User age]]. Also [[Template talk:Age]] is showing expression errors where I assume it did not previously. – [[User:Wbm1058|wbm1058]] ([[User talk:Wbm1058|talk]]) 02:22, 31 March 2022 (UTC)
:The module is fine. I replied at [[Template talk:User age]] to say that <code>format=raw</code> is needed (for example, <code><nowiki>{{age|format=raw|21 June 1984}}</nowiki></code>). That is documented at [[Template:Age]]. [[Template talk:Age]] is showing errors because of your edit at {{tl|age/sandbox}} (no problem, but that's the reason). [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:57, 31 March 2022 (UTC)
::OK, I reverted my sandbox edit, and updated [[Template:Age#TemplateData]] to include {{param|format}}. – [[User:Wbm1058|wbm1058]] ([[User talk:Wbm1058|talk]]) 12:03, 31 March 2022 (UTC)
:::Thanks, template data is over my head. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 23:02, 31 March 2022 (UTC)
 
== A day off ==
 
So I noticed a few weeks ago that [[Template:2022 Russian invasion of Ukraine infobox]]'s date section is ahead by a day. I left a query about it [[User talk:Waldyrious#{{Age in years, months, weeks and days}} time zone?|here]] but that user couldn't answer my question and directed me here instead. My questions remain the same: is this module based on an early time zone where the current date would be March 7 rather than March 6, the current date in Ukraine? And is there a way to fix that so the information displayed is accurate? Tagging @[[User:Johnuniq|Johnuniq]] as the top editor here. [[User:QuietHere|QuietHere]] ([[User talk:QuietHere|talk]]) 14:54, 6 March 2023 (UTC)
:[[Template:2022 Russian invasion of Ukraine infobox]] uses the following template. It should use the second example which is exactly the same but clearer.
:*<code><nowiki>{{Age in years, months, weeks and days|day1=24|month1=2|year1=2022|day2=|month2=|year2=|duration=yes}}</nowiki></code> → {{Age in years, months, weeks and days|day1=24|month1=2|year1=2022|day2=|month2=|year2=|duration=yes}}
:*<code><nowiki>{{Age in years, months, weeks and days|24 February 2022|duration=yes}}</nowiki></code> → {{Age in years, months, weeks and days|24 February 2022|duration=yes}}
:The template is based on UTC time, the same as that shown by recent changes or histories at Wikipedia. Your original question was written at 14:29, 24 February 2023 UTC and said that the template was showing "(1 year and 1 day)" instead of exactly one year. The reason it showed an extra day during 24 Feb 2023 is the duration=yes parameter. That tells the template to include the extra day. For example, a meeting starting at 9:00am on 23 Feb and finishing at 5:00pm on 24 Feb had a duration of two days. I would have to examine the code to remind myself how the template handles times but that is rather unimportant due to my next piece of news copied from my comment at [[Template talk:Age in years and days]]: {{tq|1=The template gives the correct results at the time the page is "purged" (see [[WP:PURGE]]). Readers see a cached copy of the html to save the overhead of the server having to regenerate the page from the wikitext. The fix is edit the page then click publish without making any changes and with no edit summary. That updates template results.}} In the context of the problem you report, that is saying that the displayed years, months, weeks and days will not change until someone purges the template. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 04:38, 7 March 2023 (UTC)
::Tried a few different purge options but they haven't made a noticeable difference. [[User:QuietHere|QuietHere]] ([[User talk:QuietHere|talk]]) 12:22, 7 March 2023 (UTC)
:::I would need a link to the page in question (is it an article? the template?) and a copy/paste of the text that is wrong. You might add one thing that you tried to fix it. Which page did you edit then click publish? [[Template:Russian invasion of Ukraine (2022–present) infobox]] currently says "(1 year, 1 week and 6 days)" which looks correct. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 06:51, 8 March 2023 (UTC)
::::The infobox exists solely as a template call on [[Russian invasion of Ukraine (2022–present)]] so the concern should be with the template page. But I've tried purges on both pages and neither changed anything. And no, by my count that's still a day ahead. The day we're starting with is Feb. 24 which was two weeks ago on Friday. As today is Wednesday, two days before Friday, that would make it five days since last Friday, March 3. I've even tried adding an end date and it still calculates one extra day than there should be no matter what day I enter. [[User:QuietHere|QuietHere]] ([[User talk:QuietHere|talk]]) 15:39, 8 March 2023 (UTC)
{{od|4}}Here is the template from Thursday 24 February 2022 to Friday 10 March 2023, including the start and end dates (because duration=yes):
*<code><nowiki>{{Age in years, months, weeks and days|24 February 2022|10 March 2023|duration=yes}}</nowiki></code> → {{Age in years, months, weeks and days|24 February 2022|10 March 2023|duration=yes}}
It's from a Thursday to a Friday, inclusive, so there must be one day left over, as shown by the template. A [https://www.timeanddate.com/date/durationresult.html?y1=2022&m1=02&d1=24&y2=2023&m2=03&d2=10&ti=on reliable calculator] doing the same calculation says:<br>From and including: Thursday, 24 February 2022<br>To and including: Friday, 10 March 2023<br>Result: 380 days<br>It is 380 days from the start date to the end date, end date included.<br>Or 1 year, 15 days including the end date.<br>Or 12 months, 15 days including the end date.<br>That agrees with the template. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:25, 9 March 2023 (UTC)
 
:Okay, now I've figured out where the confusion lies. February 24, 2022 was a Thursday as you said, whereas this year it was a Friday. I assumed that "one year" in this case would mean from Feb. 24 to Feb. 24 exactly, but in this case I guess it's going from one Thursday to the next and counting from there. Maybe? Or maybe it's something else like that. But this whole time, I'd been counting from Friday, Feb. 24, 2023, which is why my count was different by one. Now I'm not sure if that means that I'm wrong and the template has been right this whole time, but at least that's figured out. [[User:QuietHere|QuietHere]] ([[User talk:QuietHere|talk]]) 02:50, 9 March 2023 (UTC)
:Although that could also mean absolutely nothing. It's not very clear to me. [[User:QuietHere|QuietHere]] ([[User talk:QuietHere|talk]]) 02:57, 9 March 2023 (UTC)
::The calculation to get 1 year, 2 weeks and 1 day is like this:
::*24 Feb 2022 to 23 Feb 2023: 1 year exactly including the start and end dates
::*24 Feb 2023 to 9 March 2023: 2 weeks exactly including the start and end dates
::*10 March 2023: 1 day including the end date because duration=yes is used
::[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:59, 9 March 2023 (UTC)
:::Oh, I see now. I just missed you using the word "inclusive" above. So it's intentionally designed to be inclusive? Should that not be changed, or is that preferred? [[User:QuietHere|QuietHere]] ([[User talk:QuietHere|talk]]) 04:26, 9 March 2023 (UTC)
::::I explained the theory of duration=yes above. The template is doing what it was told to do. Whether or not duration=yes should be used is something to be discussed at the talk page of [[Template:2022 Russian invasion of Ukraine infobox]] with a mention at one or two article talk pages where the template is used. If duration=yes is used, the template will be a bit misleading for the first few hours each day because the full day will be included. However, the template will be correct towards the end of the day because that day should be included. All that is a bit irrelevant because, as mentioned above, purging is needed to update the display. I would include it and forget about the purging issue except for important days such as the anniversary and hopefully there won't be many more of them. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 06:25, 9 March 2023 (UTC)
 
== Example for using age_generic from another module ==
Line 463 ⟶ 46:
: Johnuniq, there's noting personal{{snd}} I'm addressing ''you'' about the current situation only because you are the one who introduced <code>abbr_on</code> but in that edit's summary did not explain why, neither can I find anything reasonable on this discussion page, nor the pages of the templates this option was supposed to reproduce. So you definitely know about the situation and its history much more that I do, thus I'm asking you why this has happened without any regard for WP:MOS. Since you're also much more familiar with the tools, it would help if you can find how much and where {{tlx|time interval}} with {{para|abbr|on}} is used to assess how it will be affected by my proposed correction. (Regarding abbreviations in {{tlx|age for infant}}, it looks like an example of somebody's made-up nonsense: no explanations why standard notation can't be used for standard units, plus searching Google for {{google|infant age "dys"}} suggests that it's not even some established jargon in any field.) And yes, if Huntster and JFG can help, it would be appreciated, because I also didn't find any justification for the current behavior of "abbr" in their comments at [[Template talk:Time interval]]. — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 04:38, 16 July 2024 (UTC)
:[[File:Red information icon with gradient background.svg|20px|link=|alt=]] '''Not done for now:''' please establish a [[Wikipedia:Consensus|consensus]] for this alteration '''[[Wikipedia:Edit requests|before]]''' using the {{Tlx|Edit template-protected}} template.<!-- Template:ETp --> Okay, two things here. First, Mikhail, Johnuniq has indicated that they were not the one that decided what the module outputs, and I believe them. Their statement says that they simply took the existing templates and converted them to a module; if a template used "improper" abbreviations before the shift, they were ported into the module. Please don't put words into their mouths when they have sufficiently explained their role in the creation of this module.
:Second, I am going to close this request until consensus can be determined. Let's not worry about ''why'' the module is the way it is, but whether it should be changed. For example, does it make sense to have different abbrevs for "infant" and "non-infant" statuses? Should this module be updated to better conform to the MOS? [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 12:24, 16 July 2024 (UTC)
::Thanks for your considered words, Primefac. Regarding this issue, I no longer have skin in this game as I've mostly abandoned en.wiki, but that said I've never been one to treat MOS as gospel that must be rigidly adhered to. It is a guideline that editors ''can'' use to create a more uniform appearance for the project, but following it is not mandatory. If you think it should be, then get it promoted to policy. Now, non-breaking spaces are a fine change to make, and a good call to keep things from wrapping. However, I don't think that changing "m" to "min" here is good, since in most circumstances it should be obvious based on how and where it's being used. (As for {{tl|Age for infant}}, what it prescribes ''is'' weird, but "days" doesn't seem to abbreviate in actual application, so who knows what's going on there.) <span style="font-variant:small-caps; white-space:nowrap; text-shadow:3px 2px 6px slateblue;">— [[User:Huntster|Huntster]] <small>([[User talk:Huntster|t]] [[Special:Emailuser/Huntster|@]] [[Special:Contributions/Huntster|c]])</small></span> 16:06, 16 July 2024 (UTC)
:: {{reply|Primefac}} The general consensus has been established in the MOS:NUM discussion I've linked above. From [[WP:CONLEVEL]], it should prevail over any local consensus (which, regarding the current wrong format, wasn't really established anywhere). Moreover, almost all articles using {{para|abbr|on}} found by Johnuniq (see below) are about astronomy or spaceflights, and their corresponding [[Wikipedia:WikiProject Astronomy/Manual of Style]] and [[Wikipedia:WikiProject Spaceflight/Style guide]] have also established consensus to "follow the main Manual of Style"/"conform to the Wikipedia:Manual of Style", only with some stricter requirements to use UTC, 24-hour time and SI units (in which "m" doesn't mean "minute"). If you think that some other consensus needs to be established or changed, please tell explicitly. (And please explain what exactly did you mean by "don't put words into their mouths" or apologize.) — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 04:43, 21 July 2024 (UTC)
:::I'll give a couple more days for feedback, but so far I am not seeing any significant opposition to the proposed update with the few comments that have come in the last few days. [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 12:09, 21 July 2024 (UTC)
If anyone wants to examine how abbr=on is used, see [[User:Johnuniq/sandbox]] ([[Special:PermanentLink/1234955794|permalink]]) which shows 297 {{tl|time interval}} in 77 articles. These are the only ones that used abbr=on in the all-articles dump from 1 July 2024. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 00:53, 17 July 2024 (UTC)
:Inspecting all occurrences of {{tl|age in days}} shows that none use <code>show unit=abbr</code>. Similarly, none of {{tl|age for infant}} use <code>abbr=on</code>. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 02:20, 17 July 2024 (UTC)
I changed {{tl|Time interval}} to use [[Module:Age/sandbox]] and edited the latter to add the separator for <code>abbr=on</code>. I don't have an opinion on the outcome but I've looked at a couple of articles from my list linked above and the space looks odd to me. Perhaps I'm just used to the extreme abbreviated version? At any rate, it would be good to get opinions from editors currently interested in affected articles rather than rely on a guideline that may or may not throw light on what should happen in these cases. An article which uses a lot of these is [[Uncrewed spaceflights to the International Space Station]] which currently has a mixture of fixed-text durations such as "13&nbsp;days, 12&nbsp;h, 35&nbsp;min" contrasted with "84&nbsp;d 7&nbsp;h 52&nbsp;m" from the template. Using "84&nbsp;d 7&nbsp;h 52&nbsp;min" looks weird to me although even a tiny discussion somewhere showing support would help. Following is an example from that article showing durations without and with the space.
*84d 7h 52m
*84&nbsp;d 7&nbsp;h 52&nbsp;m
If the mixture of days/h/min were wanted, something could be arranged. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:11, 22 July 2024 (UTC)
: The correct short format for these examples is "13&nbsp;d 12&nbsp;h 35&nbsp;min" and "84&nbsp;d 7&nbsp;h 52&nbsp;min"{{snd}} using "min" for minutes, not mixing words with unit symbols, and without commas ("13&nbsp;days, 12&nbsp;h, 35&nbsp;min" is a list of three different durations). An "extreme abbreviated version" [[ISO 8601#Durations|would be]] "P13DT12H35M" and "P84DT7H52M", but it's not what we need here. — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 18:34, 22 July 2024 (UTC)
 
OK, {{u|Primefac}} and {{u|Johnuniq}}, since you haven't made any progress in the past week and apparently wanted some broader discussion, where do you want it to happen: [[WT:MOSDATE]], [[WT:MOS]], [[WP:VPPOL]], or somewhere else? — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 01:25, 29 July 2024 (UTC)
:There should be an attempt to get opinions from editors interested in the articles that would be affected by the proposed change. Given a few days for people to express an opinion, even a tiny amount of support would convince me. We are discussing what is essentially trivia because anyone capable of reading the articles where abbr=on is used would be able to work out what a duration of 2h 34m meant, and writing 2&nbsp;h 34&nbsp;min instead would only be done to satisfy those with an itch. I don't care what people want, so long as content builders have a say. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:09, 29 July 2024 (UTC)
:: "Would be able to work out" is not a valid argument. For example, everybody can understand "illogical punctuation", but [[MOS:LQ]] requires using the "logical" one for consistency. And let me remind again about [[WP:CONLEVEL]], that few editors of particular articles cannot override the general rules (especially when they've already explicitly agreed to follow WP:MOS); if they want to, the exceptions must be discussed at [[WT:MOS]] (or its relevant subpage). So where exactly do you want to get the opinions? — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 03:34, 29 July 2024 (UTC)
 
I've asked for clarification at [[Wikipedia:Village pump (policy)#Templates and WP:MOS]]. — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 00:39, 1 August 2024 (UTC)
 
:(came from village pump) I'm not someone involved with the relevant articles, but I do agree that "13 d 12 h 35 min" looks very odd, "13d 12h 35m" is (to me) more natural (due to the consistent abbreviations) and easier to read. The latter point is because the extra spaces break up the content into 6 separate chunks rather than the intended 3 and so I have actively work to associate the abbreviation with the number. This is even worse when there are single-digit values "4 d 6 h 3 m" is bordering on gobledook while "4d 6h 3m" is coherent and understandable at a glance. I can understand a preference for "min" over "m" when used in isolation (e.g. "16m" is less clear than "16 min") but when used with hours and/or seconds the extra two letters add nothing. [[User:Thryduulf|Thryduulf]] ([[User talk:Thryduulf|talk]]) 01:03, 1 August 2024 (UTC)
::Same here. And I agree. In this kind of complex abbreviation, the MOS guidelines might not lead to the best solution. It might be good to document at the MOS an acceptable alternative style for such multi-part integer-based quantities; they don't necessarily need to be done the same way as typical values and units (e.g. 3.6 V). [[User:Dicklyon|Dicklyon]] ([[User talk:Dicklyon|talk]]) 04:38, 1 August 2024 (UTC)
::Reviewing the table with the mixed-units example in the MOS, I see that time duration is the only 3-part mixed unit case they talk about, and the example "1 h 30 min 7 s" just looks odd, compared to most of the others (but not as odd as the two-part "1 US fl pt 8 US fl oz", which I hope we never see anywhere). So, instead of asking here, I'd say take it up at MOS, and see if you can get "1h 30m 7s" approved as an OK alternative, especially given that such forms may be in wide use already. [[User:Dicklyon|Dicklyon]] ([[User talk:Dicklyon|talk]]) 04:55, 1 August 2024 (UTC)
:I saw the note at the village pump. Johnbod's example:
:* 84d 7h 52m
:* 84 d 7 h 52 m
:is the the key bit of information for me. The first is better because I can figure out what it means at a glance. The one with the spaces looks like someone's notes for a [[Bingo (American version)]] game. I'm sure that either would make sense in context, and I'm sure I could figure it out, but the first is more obvious.
:Also, if this is getting used in infoboxes or data tables, then the very small savings in the width might be wanted. [[User:WhatamIdoing|WhatamIdoing]] ([[User talk:WhatamIdoing|talk]]) 03:23, 3 August 2024 (UTC)
There are two issues here: spaces or no spaces between numbers and abbreviations, and whether the abbreviation for minute(s) should be "m" or "min". On the latter question, the longer abbreviation is asserted to be required due to ambiguity with "month", however in practice that only exists when it it appears alone - when accompanied by any other unit of time (hours, seconds, days, years) both are unambiguous due to context. [[User:Thryduulf|Thryduulf]] ([[User talk:Thryduulf|talk]]) 10:07, 3 August 2024 (UTC)
 
Although I'm a bit late to the party, I fully agree with remarks by {{u|Johnuniq}}, {{u|WhatamIdoing}}, {{u|Thryduulf}}, {{u|Dicklyon}} and {{u|Huntster}}. The abbreviated format "15d 8h 34m" is more legible than the MOS-derived "15 d 8 h 34 min", especially in the context of long lists of spaceflights or other events. Let's keep this "exception" the rule here. — [[User:JFG|JFG]] <sup>[[User talk:JFG|talk]]</sup> 04:34, 10 September 2024 (UTC)
 
== df and mf with bad values ==
 
@[[User:Johnuniq|Johnuniq]] could you please add usages of {{para|df}} or {{para|mf}} with any value other than "yes" or "y" to [[:Category:Age error]]? I'm looking at [https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=Birth+date+and+age the report] and there are many errors with df that are left uncaught. [[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 09:06, 6 April 2025 (UTC)
:I'm afraid cruft like that accumulates when parameters are not closely checked. The module copied what the templates did because I didn't want to create too much fuss when the module was introduced. However, it's stable and if you're able to attack the maintenance I can implement your change. I'll do that in the next few days and will ping you when done. If I disappear, please remind me. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:44, 6 April 2025 (UTC)
::Yes, I can do that, that isn't a problem. I've been working on cleaning templates that I've worked at with {{tl|Start date}} and others in which I've implemented [[Module:Date time]] to handle validation. [[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 09:47, 6 April 2025 (UTC)
{{ping|Gonnym}} I'm working on this and it's finished apart from checking and thinking about the following question. The function <code>yes()</code> accepts parameters like <code>fix=yes</code> but not <code>fix=YES</code> or <code>fix=Yes</code>. That was my choice because parameters like that were introduced with Module:Age and so consistent parameter values could be required. However, lots of articles use <code>df=Y</code> or <code>df=Yes</code> etc. I would prefer to avoid lower-casing the value because wikitext like <code>df=yEs</code> is ugly and I don't think it should be accepted. Also, not lower-casing is more efficient in the module. So, I'm wondering what to accept. My plan currently accepts df=y, df=yes, df=Y, df=YES. Should we try that and see what happens? My error check only examines the <code>df</code> parameter. Any junk can still be entered for <code>mf</code> because it is ignored as it is the default at enwiki. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 07:41, 10 April 2025 (UTC)
:{{ping|Gonnym}} My code is in the sandbox for testing. As mentioned, <code>mf</code> is ignored because it is the default here. Valid <code>df</code> values are y, yes, Y, Yes, YES. The error message in the following examples would also include [[:Category:Age error]] if in an article.
:*<code><nowiki>{{Birth date and age/sandbox|1 Feb 1988}}</nowiki></code> → {{Birth date and age/sandbox|1 Feb 1988}}
:*<code><nowiki>{{Birth date and age/sandbox|1 Feb 1988|mf=yeah}}</nowiki></code> → {{Birth date and age/sandbox|1 Feb 1988|mf=yeah}}
:*<code><nowiki>{{Birth date and age/sandbox|1 Feb 1988|df=}}</nowiki></code> → {{Birth date and age/sandbox|1 Feb 1988|df=}}
:*<code><nowiki>{{Birth date and age/sandbox|1 Feb 1988|df=Yes}}</nowiki></code> → {{Birth date and age/sandbox|1 Feb 1988|df=Yes}}
:*<code><nowiki>{{Birth date and age/sandbox|1 Feb 1988|df=yeah}}</nowiki></code> → {{Birth date and age/sandbox|1 Feb 1988|df=yeah}}
{{#invoke:convert/tester|compare|Age|prefix=:*}}
:Please have a look. I can update the main module when ready. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 06:26, 12 April 2025 (UTC)
::I updated the main module. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:39, 14 April 2025 (UTC)
:::Around 160 pages fixed so far. Unrelated to the above changes, [[Opera Mini]] and [[Tarbha Wale Baba]] are the only errors left which I can't fix. Tarbha Wale Baba does not seem like an error, as the dates are what the article says they are. [[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 08:45, 15 April 2025 (UTC)
::::Thanks, that's great. I saw those two pages earlier. Dealing with the second will be interesting because it's obvious nonsense (lived more than 150 years). I'm busy for a few days and will look later. They are not really our problem. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 08:56, 15 April 2025 (UTC)
 
== Birth year and age ==
 
Could the module be modified so that the age can be calculated without the specific day? Currently we have {{tl|Birth year and age}} which does it, but {{tl|Birth date and age}} which can't, but there really is no reason to have these two be different templates. [[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 08:20, 16 April 2025 (UTC)
:Too much turmoil here at the moment for me to think about that. Meanwhile, a factor to consider is that the templates have very different outputs. Following shows two examples from [[Special:ExpandTemplates]]:<source lang=moin>
{{Birth year and age|1970}}
1970 (age&nbsp;54&ndash;55)
 
{{Birth date and age|1 Feb 1970}}
Second, I am going to close this request until consensus can be determined. Let's not worry about ''why'' the module is the way it is, but whether it should be changed. For example, does it make sense to have different abbrevs for "infant" and "non-infant" statuses? Should this module be updated to better conform to the MOS? [[User:Primefac|Primefac]] ([[User talk:Primefac|talk]]) 12:24, 16 July 2024 (UTC)
<span style="display:none"> (<span class="bday">1970-02-01</span>) </span>February 1, 1970<span class="noprint ForceAgeToShow"> (age&nbsp;55)</span>
</source>[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:07, 16 April 2025 (UTC)
::The second one is better as it produces the hCalendar. [[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 09:25, 16 April 2025 (UTC)