Module talk:Age: Difference between revisions

Content deleted Content added
m Archiving 2 discussion(s) to Module talk:Age/Archive 1) (bot
 
(101 intermediate revisions by 19 users not shown)
Line 1:
{{talk header}}
==Module:Age==
{{Permanently protected}}
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.
{{User:MiszaBot/config
| algo = old(180d)
| archive = Module talk:Age/Archive %(counter)d
| counter = 1
| maxarchivesize = 150K
| archiveheader = {{Talk archive navigation}}
| minthreadstoarchive = 2
| minthreadsleft = 4
}}
 
== Example for using age_generic from another module ==
{| class="wikitable" style="text-align: center;"
! Parameters to template !! Result from <code><nowiki>{{age in days}}</nowiki></code> !! Result from <code><nowiki>{{User:Johnuniq/age days}}</nowiki></code>
|-
| <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}}
|}
 
It will be fine to have some examples in documentation. Thanks! [[User:A.sav|A.sav]] ([[User talk:A.sav|talk]]) 20:00, 17 November 2023 (UTC)
{| class="wikitable" style="text-align: center;"
:If you spell out what is wanted I might be able to provide advice. However, age_generic is not intended to be called by another module. It's purpose is given in the documentation at [[Module:Age]]. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:48, 18 November 2023 (UTC)
! Parameters to template !! Result from <code><nowiki>{{gsd}}</nowiki></code> !! Result from <code><nowiki>{{User:Johnuniq/gsd}}</nowiki></code>
::I need {{tl|age in years, months and days}} function in module. Thanks! [[User:A.sav|A.sav]] ([[User talk:A.sav|talk]]) 08:17, 18 November 2023 (UTC)
|-
{{od|2}}Simplest would be to expand the template like this:
| <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}}
<syntaxhighlight lang="lua">
|-
local function main(frame)
| <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}}
local date1 = '1 April 1980'
|-
local date2 = '20 July 1990'
| <code><nowiki>(none)</nowiki></code> || {{gsd}} || {{User:Johnuniq/gsd}}
local result = frame:expandTemplate({title = 'age in years, months and days', args = {date1, date2}})
|}
-- result = '10 years, 3 months and 19 days'
 
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
</syntaxhighlight>
</pre>
[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 08:36, 18 November 2023 (UTC)
 
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 ==
 
:Thanks, but there are 200 such templates on page. It seems it will be too expensive to use such native implementation. [[User:A.sav|A.sav]] ([[User talk:A.sav|talk]]) 08:43, 18 November 2023 (UTC)
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.
::What page? What module? Module:Age just gathers the parameters (date1 and date2) and calls [[Module:Date]] to get the numbers (10, 3, 19 in above example), then inserts the years/months/days text. Another module could do that too. Or, you could call age_generic and pass something that looks like a frame sufficiently well to do what age_generic needs as can be seen by inspecting its code. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:26, 18 November 2023 (UTC)
:::I want to localize [[:no:Module:Liste over eldste personer]] for Bulgarian. I did it for Belorussian, Serbian and Romanian, and Russian localization is also based on my Belorussian localization. Well, I can even derive months/days calculation from bulgarian template implementation, but I want to reuse existed Age module. [[User:A.sav|A.sav]] ([[User talk:A.sav|talk]]) 13:12, 18 November 2023 (UTC)
 
== abbr=on violates MOS ==
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
 
{{edit template-protected|answered=yes}}
{{age in days nts/sandbox|1800-1-1|1800-9-1|prefix=over}}
Using <code>abbr=on</code> produces output like "1d 2h 3m 5s", which violates [[MOS:UNITS]] (see "expressing time durations"). The correct short format must have no-break spaces between numbers and units, and use "min" for [[minute]]s.
<span data-sort-value="7002243000000000000♠"></span>over 243
 
Namely, please add <code>sep = '&amp;nbsp;',</code> and change <code>m = 'm',</code> to <code>m = 'min',</code> to <code>abbr_on</code> [[Module:Age#L-474--L-481|here]]. — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 05:10, 15 July 2024 (UTC)
{{age in months/sandbox|1800-1-1|1800-9-1|prefix=over|sortable=on}}
:The reason that modules such as this require advanced rights to edit is to reduce the churning that would occur from normal bold editing. The spacing has been the way it is for a very long time and more than a mention of a guideline is needed to effect a change. For example, there would need to be a reasonable attempt to work out where the abbr=on option is used and whether there are reasons for it being the way it is. Also, some wider discussion before a change would be required. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 05:46, 15 July 2024 (UTC)
<span data-sort-value="7002243000000000000♠"></span>over 8
:: As the first paragraph of [[MOS:NUM]] says, "The aim is to promote clarity, cohesion, and consistency, and to make the encyclopedia easier and more intuitive to use", so it's not that "more than a mention of a guideline is needed" to ensure conformance, but quite the opposite{{snd}} [[WP:LOCALCONSENSUS|any deviation from the MOS must be justified]]. That particular part of MOS:NUM has existed in its current state since 2016, after [[Wikipedia_talk:Manual_of_Style/Dates_and_numbers/Archive_155#Wrong/contradictory_examples_for_time_durations_in_"Mixed_units"|this discussion]], which you definitely should have seen (based on your participation in other topics on that page at that time) but not objected. Between 2014 and 2016, there was some inconsistency due to an accidental mistake; but as far as I can tell, minutes were always "min", not "m" (see [[MOS:NUM#Specific units]]), and the unspaced format was never considered acceptable. So it seems to me that <code>abbr_on</code> was {{diff||726734776|prev|introduced here}} without enough thought and apparently without discussing its consistency with WP:MOS or any external standard or style guide. The fact that nobody has complained yet [[WP:BEENHERE|doesn't mean]] that it should not be corrected. I personally didn't notice such use of this module in any articles I read or edit until very recently, in [[Special:Permalink/1234163587#List of spacecraft|Boeing Starliner §&nbsp;List of spacecraft]]. — [[User:Mikhail Ryazanov|Mikhail Ryazanov]] ([[User talk:Mikhail Ryazanov|talk]]) 20:03, 15 July 2024 (UTC)
:::It sounds like you think I'm somehow responsible for the current situation. I wrote [[Module:Age]] but that was to emulate what the templates that it replaced did (without some errors), and to add some extras that others requested. I don't recall expressing an opinion on the spacing issue raised here. I think templates and modules should follow consensus from specific discussions. I have no idea where abbr=on is used but I do know that an effort should be made to work that out before making a change that conceivably could affect hundreds of articles. Guidelines are great but some thought about consequences should occur before changing how templates have worked for several years. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:11, 16 July 2024 (UTC)
A quick look makes me think that abbr=on is only used in:
*{{tl|age in days}} if <code>|show&nbsp;unit=abbr</code> is used
*{{tl|time interval}} if <code>|abbr=on</code> is used
{{tl|age for infant}} displays units but never like <code>|abbr=on</code>. I can't think of any other templates using [[Module:Age]] where a unit like <code>d</code> is shown. {{ping|JFG|Huntster}} You are both away at the moment but on return you might like to offer an opinion on this request, or report where abbr=on has been used. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 03:13, 16 July 2024 (UTC)
: 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)
{{time interval/sandbox|1800-1-1|1800-9-1|prefix=over|sortable=on}}
: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)
<span data-sort-value="7002243000000000000♠"></span>over 8&amp;nbsp;months
:: "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)
{{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)
 
:(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)
== Sorting in tables ==
::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)
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
 
== df and mf with bad values ==
{{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)
 
@[[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)
== Template-protected edit request on 14 September 2019 ==
: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 ==
{{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)
 
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)
== Localization of time zone for sr.wikipedia ==
: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}}
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)
<span style="display:none"> (<span class="bday">1970-02-01</span>) </span>February 1, 1970<span class="noprint ForceAgeToShow"> (age&nbsp;55)</span>
: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)
</source>[[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 09:07, 16 April 2025 (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 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:UTC уместо CET/CEST времена за доб у датуму рођења]] (currently it holds 3 March because I tested it on 2 March night when 3 March was about to come).
::The second one is better as it produces the hCalendar. [[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 09:25, 16 April 2025 (UTC)
::Yes, they do not. Both Belgrade and Banja Luka / Istočno Sarajevo as capitals of most numerous (by Serbian language speaking population) Serbian territory capitals 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 you 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 bracket text generated by [[:sr:Шаблон:Датум рођења]]. --[[Special:Contributions/5.43.82.5|5.43.82.5]] ([[User talk:5.43.82.5|talk]]) 22:23, 3 March 2020 (UTC)