Module talk:Age: Difference between revisions

Content deleted Content added
m Archiving 2 discussion(s) to Module talk:Age/Archive 1) (bot
 
(17 intermediate revisions by 6 users not shown)
Line 10:
| minthreadsleft = 4
}}
 
== 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 96 ⟶ 65:
 
:(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)
:::Thanks, template dataI isupdated overthe mymain headmodule. [[User:Johnuniq|Johnuniq]] ([[User talk:Johnuniq|talk]]) 2309:0239, 3114 MarchApril 20222025 (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}}
<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]]) 0309:5907, 916 MarchApril 20232025 (UTC)
::The second one is better as it produces the hCalendar. [[User:Gonnym|Gonnym]] ([[User talk:Gonnym|talk]]) 09:25, 16 April 2025 (UTC)