| This is the talk page for discussing improvements to the Age module. |
|
| Archives: 1Auto-archiving period: 6 months |
| Module:Age is indefinitely protected from editing as it is a heavily used or highly visible module. Substantial changes should first be proposed and discussed here on this page. If the proposal is uncontroversial or has been discussed and is supported by consensus, editors may use {{edit template-protected}} to notify an administrator or template editor to make the requested 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)
Per this tfd I have refactored the module's code for {{dda}} and {{bda}} so that they will respect the format of the input date. To be clear:
|df=yes)
{{bda|2 May 1990}} → 2 May 1990{{bda|2 May 1990}} → May 2, 1990|mf= & |df= still work as before and will override the default behaviorThe code diff can be see here.
Zackmann (Talk to me/What I been doing) 06:30, 5 December 2025 (UTC)
|mf= & |df= still work as previous)I have started looking at the changes. They are good but I haven't done my full check of results yet. Meanwhile, here are some differences to think about.
{{Birth date and age|2001|4|1}} → April 1, 2001{{Birth date and age/sandbox|2001|4|1}} → April 1, 2001{{Birth date and age|year=2001|month=4|day=1}} → April 1, 2001{{Birth date and age/sandbox|year=2001|month=4|day=1}} → April 1, 2001{{Death date and age|2005|4|12|2000|4|13}} → April 12, 2005 (aged 4){{Death date and age/sandbox|2005|4|12|2000|4|13}} → April 12, 2005 (aged 4)More in a day or two. Johnuniq (talk) 06:03, 6 December 2025 (UTC)
Date(...,y,m,d) then d.format will be 'dmy'. Since .format is read-only, there is no 'setter' to override that. Not sure what the best solution is... I guess we could change the formatting so that instead of constructing the date in 'ymd' it constructs it in 'mdy', but that seems like a sizable refactor. Maybe the easier solution is to refactor Module:Date to allow you to set the value for the format associate with a specific instance of a date? Off hand that seems like it would require less code changes and therefore be less risky overall? Open to your thoughts and suggestions. Zackmann (Talk to me/What I been doing) 19:14, 6 December 2025 (UTC)
'mdy' as part of the date constructor to set the default date format. This way, no uses of Module:Date should change, and with this little change, there should be no changes to the bda/dda calls that are using the format {{bda|yyyy|mm|dd}}. You will note that your examples above now produce the same results. Zackmann (Talk to me/What I been doing) 22:53, 6 December 2025 (UTC)@Zackmann08: I have reworked the module for a simpler change. It would be better if Module:Date is only changed if needed, and I don't think it is. Also, I suspect the changes to Module:Age would change the birth/death date format defaults for a couple of other language Wikipedias where df is the default, if they ever updated their code from here. The minor issue mentioned in my 6 December 2025 comments above concerns examples like {{Birth date and age|2001|4|1}} where Module:Date reports that the date format is dmy. It does that because date:text() would give dmy with that input. With that example, there is no specified date format and my change to Module:Age takes that into account. Please have a look and see what you think about the current sandbox code. I'm going to need another couple of days to get back to this for a final check but I think this should work. The following shows the current modules.
Johnuniq (talk) 04:12, 9 December 2025 (UTC)
@Johnuniq: on the heels of the successful merge of {{death-date and age}} that we achieved above, I'm looking at doing the same thing with the birth age templates. Behold the clusterf&$k that is the birth age templates...
{{bda|12 December 2020}} → 12 December 2020{{bda|December 2020}} → Error: Need valid birth date: year, month, day (should display age as 4-5){{bda|2020|12}} → Error: Need valid birth date: year, month, day (should display age as 4-5){{b-da|12 December 2020}} → 12 December 2020 (age 5){{b-da|December 2020}} → December 2020 (age 5) (should display age as 4-5){{b-da|2020}} → 2020 (age 6) (should display age as 4-5)NOTE the "should display" comments above are as of Dec 15, 2025. Those will obviously change in the future...
Before I start down this rabbit hole, I wanted to gauge your willingness to help as you did previously, and ensure that this seems like a worthwhile effort. Any thoughts on the matter? Obviously there is no rush on it... Zackmann (Talk to me/What I been doing) 18:52, 15 December 2025 (UTC)
@Gonnym, Ahecht, and Johnuniq: I have now come across 4 separate pages with errors related to Template:Age in years, months, weeks and days (See: Category:Pages using age template with invalid date). NONE of them have had any recent changes and I don't see any recent changes to the template either... I'm totally lost as I cannot find any recent changes that may have caused this to start breaking. Any help greatly appreciated! Zackmann (Talk to me/What I been doing) 22:50, 31 January 2026 (UTC)
Numbers should perhaps be formatted via module:formatnum or mw.lang.formatnum(). This would reduce effort in localizing the module for other wikis. Ipr1 (talk) 15:20, 19 February 2026 (UTC)
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.