Jump to content

Module talk:Age

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

df and mf with bad values

[edit]

@Johnuniq could you please add usages of |df= or |mf= with any value other than "yes" or "y" to Category:Age error? I'm looking at the report and there are many errors with df that are left uncaught. Gonnym (talk) 09:06, 6 April 2025 (UTC)[reply]

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. Johnuniq (talk) 09:44, 6 April 2025 (UTC)[reply]
Yes, I can do that, that isn't a problem. I've been working on cleaning templates that I've worked at with {{Start date}} and others in which I've implemented Module:Date time to handle validation. Gonnym (talk) 09:47, 6 April 2025 (UTC)[reply]

@Gonnym: I'm working on this and it's finished apart from checking and thinking about the following question. The function yes() accepts parameters like fix=yes but not fix=YES or fix=Yes. 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 df=Y or df=Yes etc. I would prefer to avoid lower-casing the value because wikitext like df=yEs 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 df parameter. Any junk can still be entered for mf because it is ignored as it is the default at enwiki. Johnuniq (talk) 07:41, 10 April 2025 (UTC)[reply]

@Gonnym: My code is in the sandbox for testing. As mentioned, mf is ignored because it is the default here. Valid df values are y, yes, Y, Yes, YES. The error message in the following examples would also include Category:Age error if in an article.
  • {{Birth date and age/sandbox|1 Feb 1988}} (1988-02-01) February 1, 1988 (age 37)
  • {{Birth date and age/sandbox|1 Feb 1988|mf=yeah}} (1988-02-01) February 1, 1988 (age 37)
  • {{Birth date and age/sandbox|1 Feb 1988|df=}} (1988-02-01) February 1, 1988 (age 37)
  • {{Birth date and age/sandbox|1 Feb 1988|df=Yes}} (1988-02-01) 1 February 1988 (age 37)
  • {{Birth date and age/sandbox|1 Feb 1988|df=yeah}} (1988-02-01) February 1, 1988 (age 37)[Parameter df=yeah is invalid]
  • Module:AgeModule:Age/sandboxdifferent (diff)
Please have a look. I can update the main module when ready. Johnuniq (talk) 06:26, 12 April 2025 (UTC)[reply]
I updated the main module. Johnuniq (talk) 09:39, 14 April 2025 (UTC)[reply]
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. Gonnym (talk) 08:45, 15 April 2025 (UTC)[reply]
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. Johnuniq (talk) 08:56, 15 April 2025 (UTC)[reply]

Birth year and age

[edit]

Could the module be modified so that the age can be calculated without the specific day? Currently we have {{Birth year and age}} which does it, but {{Birth date and age}} which can't, but there really is no reason to have these two be different templates. Gonnym (talk) 08:20, 16 April 2025 (UTC)[reply]

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:
{{Birth year and age|1970}}
1970 (age 54–55)

{{Birth date and age|1 Feb 1970}}
<span style="display:none"> (<span class="bday">1970-02-01</span>) </span>February 1, 1970<span class="noprint ForceAgeToShow"> (age&nbsp;55)</span>
Johnuniq (talk) 09:07, 16 April 2025 (UTC)[reply]
The second one is better as it produces the hCalendar. Gonnym (talk) 09:25, 16 April 2025 (UTC)[reply]

Unify error categories

[edit]

Currently we have 2 categories populated by age templates when there is an issue…

I was going to modify line 33 and retargeted this module to the first (Category:Pages using age template with invalid date) unless there is an important reason for this module to have its own error category… @Johnuniq: any objection? — Zackmann (Talk to me/What I been doing) 05:11, 26 September 2025 (UTC)[reply]

OK. I would like to say that simple is best and the convention of starting category names with "Pages using" is silly (that's literally what a category is), however, I can't stand alone against the tide of business speak so go for it. Johnuniq (talk) 05:47, 26 September 2025 (UTC)[reply]
Hey I feel ya. Hard to fight a rising tide sometimes… —Zackmann (Talk to me/What I been doing) 05:49, 26 September 2025 (UTC)[reply]

Abbreviated dates

[edit]

At a current TFD an error was raised about {{death date and age}}. The issue is that abbreviated months are replaced with the full name.

  • {{death date and age|3 Oct 2025|5 Dec 1990}} → October 3, 2025(2025-10-03) (aged 34) (should be: Oct. 3, 2025...)

Per MOS:DATE abbreviated date are allowed. Would be ideal if this template didn't force the longer form when the short form is provided.

I will also say that when you supply a df date like this, it would be great if it auto-detected that it should display in df format but that is another issue. Zackmann (Talk to me/What I been doing) 03:11, 9 October 2025 (UTC)[reply]

Merging complex stuff that has been used for years is very hard. The whole point of Module:Date and Module:Age was to provide reliable and consistent results. It seems that {{death date and age text}} accepts dates like "3 Octo 2025" and outputs the same. Is that really desirable? At any rate, there is no provision currently in {{death date and age}} to detect that an abbreviated month name was entered and therefore is wanted in the output. I don't think that "and therefore is wanted in the output" should be assumed. Just because someone entered (or pasted) "3 Oct 2025" doesn't mean that they want that as the output. The date is sometimes entered as |2025|10|3 or 2025-10-03 and those are definitely not wanted. The template is used 480,000 times and a lot of investigation and discussion notification would need to occur before changing such a fundamental way it works. A quick look at the doc for {{death date and age text}} suggests it has other features that {{death date and age}} does not have. Have they been raised at the TfD? Is it known whether they are used? Johnuniq (talk) 04:43, 9 October 2025 (UTC)[reply]
@Johnuniq: Merging complex stuff that has been used for years is very hard. Understatement... No but seriously, you make a very good point. I am making an assumption there. A few things I will say though.
  1. I don't think 3 Octo 2025 should output 3 Octo 2025. I have NEVER seen anyone abbreviate October Octo. I would say that should be considered an invalid date. But I think following the same date formats that Module:Date#L-570 spells out would make sense. I.E. October, Oct & Oct..
  2. Perhaps a better solution is to allow for an extra param following the |df=yes format. What if we did |abbr=yes I think that would be MUCH easier to implement and would require far less overhead. Additionally since it is adding a new parameter and only affecting outputs with that new parameter set, it shouldn't change any existing transclusions. I'll take a stab at implementing that in the sandbox.
  3. I do think that detecting the format (df vs mf) and respecting that if the date is entered in a string (I.E. 12 April 2010 vs April 12, 2010). I just cannot think of a situation where you would input a df string and be disappointed that you got a df string back (or an mf string and got an mf string). Plus if for some reason you did want to input a df string and have it output as an mf, you can always do |mf=yes which I think should still override the input format.
I'll take a stab at implementing #2 in the sandbox. What are your thoughts on #3? -- Zackmann (Talk to me/What I been doing) 05:36, 9 October 2025 (UTC)[reply]
@Johnuniq: ok so before I start I figured I better add some testcases... But I'm clearly doing something wrong...
  • {{death date and age|5 January 1990|6 July 1985}}→January 5, 1990(1990-01-05) (aged 4)
  • {{#invoke:age|death_date_and_age|5 January 1990|6 July 1985}}Error: Need valid death date (first date): year, month, day
What am I missing... I'm sure it is something really obvious that will result in a facepalm... Zackmann (Talk to me/What I been doing) 05:55, 9 October 2025 (UTC)[reply]
Editing Template:Death date and age shows that it passes a parameter in the frame args to Module:Age. That is how the module determines what function is wanted. The user input parameters have to be in the parent frame args. That is, you can't invoke it, you have to use the template. Last I looked, the sandbox template invokes the sandbox module. My point about "Octo" is that only a deep investigation of the wikitext used in articles would reveal what is used. Before thinking about the modules, it might better to ask at a MOS talk page about what should occur. I saw a comment in the TfD asserting that "Oct" was sometimes desirable, but is that true? What examples show that? How many of them are there? Johnuniq (talk) 06:06, 9 October 2025 (UTC)[reply]
@Fourthords: you were the one who raised the issue at the TFD. can you shed some light on Johnuniq's comments above? Do you have any examples where the abbreviated form is preferred or is this more of a hypothetical (both are valid, just curious)?
@Johnuniq: I do think that is should be supported. MOS:DATE specifically says that abbreviated months at For use in tables, infoboxes, references, etc. Only certain citation styles use abbreviated date formats. By default, Wikipedia does not abbreviate dates. My read of that is that it is allowed, so if it is allowed, then I think {{Bda}} and {{Dda}} should support it in some fashion. Whether that is by parsing the input and detecting if an abbreviation is provided (obviously more complicated to implement) or by specifying that you want the abbreviated format (via something like |abbr=yes). Help me get where you are coming from. What is the downside you are seeing to allowing this? -- Zackmann (Talk to me/What I been doing) 06:54, 9 October 2025 (UTC)[reply]
When Module:Age first appeared, there were dozens of errors due to broken dates. I fixed many of them by writing things like "1 Feb 1980" knowing that "Feb" would be recognized and translated to the standard output, and that "February 1, 1980" would be used if required. At any rate, this talk page is the wrong place to discuss whether a fundamental way that a template works should be changed. Let's wait to see a list of at least half a dozen articles where abbreviated names are clearly desirable. If the examples show a need, then start a discussion about whether the change should occur. After that, discuss how (copy input format; new parameter; or something else). That should happen somewhere else, with a meaningful notification to the relevant MOS people. Johnuniq (talk) 07:18, 9 October 2025 (UTC)[reply]
Sounds good! Appreciate the advice and information. You obviously know more of the history here and have a better view of things so I appreciate your advice and perspective. - Zackmann (Talk to me/What I been doing) 07:23, 9 October 2025 (UTC)[reply]

Test cases

[edit]

So regardless of if any changes are made to Module:Age per the current discussion, I do think it would be beneficial to have some Module:UnitTests for the module. I found that with a tiny change to the module I can call the functions directly which will allow the unit tests to function. Can you review it and merge it if it looks good? Here is the comparison. I followed the format I have seen in many other Modules. Zackmann (Talk to me/What I been doing) 07:35, 9 October 2025 (UTC)[reply]

Now this is a discussion that should be on the module talk page! Please don't reply here but I'm slow and methodical and would need quite a bit of time to ponder the fact that the frame args are referred to in several different places. Johnuniq (talk) 08:43, 9 October 2025 (UTC)[reply]
@Johnuniq: Facepalm Facepalm . Moved the discussion. Let me know if you have any questions! --Zackmann (Talk to me/What I been doing) 09:16, 9 October 2025 (UTC)[reply]
I'm occupied elsewhere at the moment. Have you thought about my "ponder" point above? I haven't thought about whether that needs thought. Johnuniq (talk) 09:19, 9 October 2025 (UTC)[reply]
I will ponder whilst you figure out if pondering is needed... Obviously no rush on this. Get to it when you can. If/when it is merged, I will start making testcases. Zackmann (Talk to me/What I been doing) 09:21, 9 October 2025 (UTC)[reply]
@Zackmann08: See my edit at Module:Age/testcases. Why not call the templates? Johnuniq (talk) 08:15, 11 October 2025 (UTC)[reply]
Because...... Looking for witty retort... Error 404. Honestly because I didn't think of that or realize that was doable. I see no reason that shouldn't work just fine. I'll do that. Zackmann (Talk to me/What I been doing) 08:18, 11 October 2025 (UTC)[reply]