Template talk:Age in years and days

message: This template does not seem to take leap days into account.  I tried measuring from Feb. 28 to Mar. 1 of the following year; 1995-1996 should be "1 year, 2 days" and 1994-1995 should be "1 year 1 day", but both are the later:
*For 1994-5:  
*For 1995-6:  
*For 1996-7:  
I think I've found a way to fix it.
--Arctic Gnome (talk • contribs) 23:11, 17 July 2007 (UTC)
replies: text: After a bunch of testing, I seem to have got it to work with leap years without screwing up the rest of the functions.  --Arctic Gnome (talk • contribs) 00:17, 18 July 2007 (UTC)
replies: text: I have also fixed the problem that was stopping this template from working right for times less than one year.  --Arctic Gnome (talk • contribs) 00:58, 18 July 2007 (UTC)
replies: text: Thanks and well done Arctic.gnome. —Moondyne 01:38, 18 July 2007 (UTC)
replies: text: No problem, it was a very educational experience for myself; I'm just starting to get the hang of the "if" statements.  I've now also fixed the plurals so if there is only one year it says "year" rather than "years".  --Arctic Gnome (talk • contribs) 02:06, 18 July 2007 (UTC)
thread_title:  Leap years 

message: This a great template, kudos to Moondyne for making it.  I think this will eventually be in many tables, so I've gone ahead and protected it.  --Arctic Gnome (talk • contribs) 02:12, 18 July 2007 (UTC)
replies: text: Actually, it was User:Hesperian who created it  on my request.  He gets the credit.  —Moondyne 07:46, 20 July 2007 (UTC)
thread_title:  Protected 

message: I think this is a great template, and it will come in very handy for many.  However, I was playing around with the template, and I noticed that it "allows" the user to input invalid dates.  In other words, the template allows for input of the following three types of invalid dates: 
* (a) dates that do not exist, such as February 30 or February 31; 
* (b) leap days of February 29 in non-leap years (e.g., February 29, 2004 should be allowed as input, but February 29, 2005 should not); and 
* (c) month and day values that are out of range (e.g., one can input a 99 for the month or a 77 for the day, etc.).  
All of these invalid dates should not be "allowed" as input ... nonetheless, they yield numerical results (which I assume are incorrect calculations).  Is there any way to fix this?  Thanks.  (Joseph A. Spadaro 19:55, 7 August 2007 (UTC)
replies: text: It would be possible to go through and tell the template to give an error result for incorrect dates, but I do not think that this is necessary.  This template essentially just takes two other templates:  and  and puts all of the numbers in the right place in each of them.  Those two templates are big ones used in tens of thousands of articles, and if you were going to tell a template to start giving error messages for bad dates, it should be there.  I think that for those two templates it has been assumed that editors of articles in which they are used should make sure that the dates are correct rather than having the template put a "cannot compute" message in the middle of articles.  --Arctic Gnome (talk • contribs) 21:38, 7 August 2007 (UTC)
replies: text:  Thanks for the background info on the template.  That is helpful to know.  Now, of course, it is assumed that editors should and will input correct dates into articles and formulas.  However, that is why they are called "errors" -- because they occur inadvertently as opposed to intentionally.  Typically, I would assume, through typo's.  The fact that these formulas spit out some form of output (I assume incorrect calculations) -- as opposed to an error message -- simply makes errors that much harder to detect and/or avoid.  That is, the algorithm should not even accept a "date" such as 99/99/99 ... much less perform calculations on it.  Thanks.  (Joseph A. Spadaro 01:14, 9 August 2007 (UTC)
replies: text: You could use the same argument that the results are incorrect of the input values are entered wrongly.  eg. digits in a year being transposed. GIGO. —Moondyne 01:29, 9 August 2007 (UTC)
replies: text:  Well, of course.  One could put forth many arguments.  However, transposing the year "82" to "28" -- while still an error -- ultilizes feasible input of a correct or valid year.  That is, even though the entry "28" (or "82") may be an error in this particular case, it can also be a non-error in another particular case.  Unlike ... say ... entering a month of "99" ... which is guaranteed to be an error in any and every case (as "99" will never be a valid entry for a month).  It's simply one more way to catch / prevent / avoid errors -- that is all that I am saying.  Furthermore, if indeed the algorithm calculates some values (results) based on invalid entries, there clearly must be some error within the algorithm.  For example, let's input two invalid dates: 55/55/1955 as the beginning date and 88/88/1988 as the ending date.  In this case, the formula calculates a result of "33 years and 1039 days" as the age.  Where and how is this non-sensical value arrived at?  The fact that any result at all is being calculated indicates that there is some inherent error within the algorithm.  Furthermore, the fact that output of "1039 days" is calculated as the result further indicates an inherent error within the algorithm.  That is, the algorithm should never -- regardless of input -- output more than 365 days ... any amount above and beyond 365 days should simply increase the year value by 1 and start the index for days over again at 0.  In other words, there should never be an output that reads "370 days" -- rather, it should read "1 year and 5 days".  The number of days should never exceed 365 and the fact that it does indicates an inherent error within the algorithm.  Thanks.  (Joseph A. Spadaro 01:46, 9 August 2007 (UTC)
replies: text: An error message would be useful, but as a second choice, to detect an input error an output "370 days" is more useful than "1 year and 5 days".--Patrick 06:25, 9 August 2007 (UTC)

text: I don't disagree with those comments, but going back to your original question: Is there any way to fix this?, Arctic.gnome answered above that such error checking and feedback would ideally need to be done at the higher level templates rather than here.  I am sure that it could be done but the downside is that such checking would probably add a lot of code to these widely used templates and I would guess that the work required and the overheads in having larger templates are just not warranted.  Templates are just shortcuts to save writing more complicated wikimarkup and I don't think they are generally intended as bulletproof interfaces. I say again, GIGO.  Cheers. —Moondyne 04:45, 9 August 2007 (UTC)
replies: text: We can't tell the template to add one to the year when the days are more than 365 because the year and the days are calculated using two completely separate templates:  and .  The first template calculates the year, then the second one calculates the number of days remaining in the last year (doing the last year lets us get the leap days right).  If someone enters an invalid date, the two other templates treat it as that many days after the last valid date; thus March 40th = April 9th.  Fixing it here would either require telling this template to look out for a slew of possible errors which would take forever; or to re-write the entire calculator from scratch, which I don't know how to do.  It still seems best to me to take this issue to the two super-templates.  --Arctic Gnome (talk • contribs) 05:36, 9 August 2007 (UTC)
replies: text: I added some documentation at Template:Age/doc about wrong input.--Patrick 06:20, 9 August 2007 (UTC)
replies: text:  I can understand and appreciate all of the above comments.  Realistically and practically, then ... perhaps the least we can do is to add some sort of notation / disclaimer to this template page as well ... (somewhat similar to the notes added by Patrick to the Template:Age/doc) ...?  Thanks.  (Joseph A. Spadaro 22:15, 9 August 2007 (UTC)
replies: text:  I added some documentation at Template:Age in years and days/doc about wrong input, consistent with the documentation added by Patrick at Template:Age/doc.  Given the thread of conversation above and the cost/benefit considerations of editing the current code, I think that the documentation about the input of invalid dates is a satisfactory solution.  (Joseph A. Spadaro 22:28, 14 August 2007 (UTC)
thread_title: Invalid dates

message: Greetings,
The template as currently written gives ages with commas. I was wondering, would it be possible to have a template that does not give commas? Modern usage has tended to not use commas in this instance because a person's age is simply one number. Hence, if someone is 17.45 years old, we are given one age. To say that someone is "17 years, 45 days old" seems a bit laborious when it comes to reading long lists, as happens with the article List of living supercentenarians.
Sincerely,
Robert Young
Ryoung122 06:50, 9 August 2007 (UTC)
replies: text: I am not sure that I am understanding your question.  Are you stating (or implying) that both of those values you cite are the same value (i.e., that "17 years, 45 days old" is the same age value as "17.45 years old")?  For they are not.  In the first case (with the comma that you are objecting to), the numeral 45 refers to the absolute number of days.  In the second case (with the decimal point), the numeral 45 refers to a decimal (or fractional) part of a year (i.e., specifically 0.45 of a year = 45% of a year = 164 days).  Two very different values.  And I have never seen the convention where a notation as 17.45 is used to represent 17 years and 45 days.  Please clarify your question.  Thanks. (Joseph A. Spadaro 07:03, 9 August 2007 (UTC)
replies: text: No, I am implying that when we use a decimal place, we recognize a person's age as one value: 17.12 years old. When using the day and date template, it recognizes a person's age as two values: "122 years, 164 days old" for Jeanne Calment instead of "122 years 164 days old." I like the lack of a comma because it helps the reader better understand that a person's age is just one value. This may not seem like a big deal until the age list is in the 'hundreds' range.Ryoung122 07:16, 9 August 2007 (UTC)

text: Ryoung asked me this question a couple of weeks ago and I answered that I thought commas seemed to be more correct grammatically.  On reflection I'm not so sure of my answer and so would like to hear others thoughts.  If it was a vote, I'd probably say Weak keep for commas but could be swayed. —Moondyne 13:06, 9 August 2007 (UTC)
replies: text:  My thoughts are as follows.  The main objection to the use of commas is merely aesthetic.  And, even at that, there is scant little aesthetic difference between the values being listed with the comma versus without the comma.  As far as grammar, I would contend that inclusion of the comma is grammatically correct.  For example:  if we declared that an age was 73 years, 4 months, and 16 days ... I think it's clear that the commas are necessary.  First, it is grammatically correct.  Second, it would be quite cumbersome (and hard on the eyes) to make sense of a string such as: 73 years 4 months 16 days.  (It is "too" compact -- and needs some visual / aesthetic separation ... i.e., comma usage.)  So, if I had to choose between "37 years, 95 days" (with comma) or "37 years 95 days" (without comma), I would advocate the former (include the comma).  Therefore, a KEEP vote.  Another consideration ... not one that I necessarily endorse ... is the format "37 years and 95 days" (replace the comma with the word "and").  Just a thought in that it does two things: (a) keeps the phrase compacted as one -- so that the age is recognized as one, not two, values; and (b) the word "and" provides enough visual and aesthetic separation (in lieu of the comma) so as to make the info manageable and not cumbersome to read / digest.  Thanks.  (Joseph A. Spadaro 22:33, 9 August 2007 (UTC)

text: I would oppose a second template as that would just lead to disagreements and one of the templates would sooner or later end up at TfD.  We need to establish a consensus and move forward.  I posted a question at the MOS talk page for wider input.. —Moondyne 07:56, 10 August 2007 (UTC)
replies: text: Regardless of the comma's position, "age ... old" is a tautology. Use "John Smith's age is 28 years 315 days" or "John Smith is 28 years 315 days old". Why not replace the comma with "and" ?Andy Mabbett | Talk to Andy Mabbett 16:59, 10 August 2007 (UTC)
replies: text: We could probably add a parameter that would give people the option of taking out the comma or replacing it with "and", but that would make this already large template even bigger.  If someone has a big problem with the comma, it might be best to have two separate templates.  --Arctic Gnome (talk • contribs) 16:23, 16 April 2008 (UTC)
thread_title: Commas

message: Someone needs to add the  to this page. It's confusing some editors who come here and realize they can't edit it. Thanks. Hersfold (t/a/c) 20:12, 21 August 2007 (UTC)
replies: text: Done. — Carl (CBM · talk) 00:05, 22 August 2007 (UTC)
replies: text:  Thanks.  (Joseph A. Spadaro 00:24, 24 August 2007 (UTC)
thread_title:  Missing protection template 

message: Is it possible to change the parameterization or make a similar template for an infants age so that it reads (age 3 mos. and 14 days.) below age 1 and (age 1 yr. and 3 mos.) between 1 yr and 2 years and just (age 3) above 2 years.--TonyTheTiger (t/c/bio/tcfkaWCDbwincowtchatlotpsoplrttaDCLaM)  14:07, 2 October 2007 (UTC)
replies: text: In case you are wondering about usage an example would be the Children section of Tiger Woods' infobox.--TonyTheTiger (t/c/bio/tcfkaWCDbwincowtchatlotpsoplrttaDCLaM)  14:08, 2 October 2007 (UTC)
thread_title:  Infant age 

message: Is there a template for calculating age in Years, months, and days?—Markles 00:02, 3 December 2007 (UTC)
replies: text: Yes! I wonder the same! It's missing.  — Preceding unsigned comment added by 2A01:E35:8A8D:FE80:4CC0:168C:F71F:D47D (talk) 00:01, 24 November 2016 (UTC)
replies: text:  PrimeHunter (talk) 10:06, 24 November 2016 (UTC)
thread_title:  Years, months, days 

message: For some very strange reason, this template is emitting a bunch of Expression error: Unrecognised punctuation character "[" messages, but only under Lynx, not under a graphical browser such as Firefox.  WTF?! —Steve Summit (talk) 22:39, 28 November 2008 (UTC)
replies: text: Turns out it's not browser-dependent, it's just that you don't normally see the error messages in a browser with stylesheets enabled.  See Wikipedia:Village pump (technical)#Bizarre interaction between age and nts templates. —Steve Summit (talk) 01:28, 29 November 2008 (UTC)
thread_title:  Browser-Dependent??!? 

message: is anyone aware of a template that calculates future and elapsed time (T+/T-) rendered: xx years, xx months, xx days.  my first choice was , however, it apparently cannot handle the future. --emerson7 17:31, 13 December 2008 (UTC)
thread_title:  elapsed time 

message: "at the age of &0000000000000113.000000113 years, &0000000000000041.00000041" - is this Google's fault, or is it somethign we can improve? --NE2 04:33, 2 November 2009 (UTC)
thread_title:  This seems to be causing problems for Google 

message: I have added this template to my userpage to show my age. I am born in 1988, and I'm 22 years old. The template says I am 21...
So it's off by a year....... Skibden (talk) 20:27, 5 October 2010 (UTC)
replies: text: Use year1|month1|day1.--Patrick (talk) 23:30, 5 October 2010 (UTC)
thread_title:  A year wrong 

message: Are displayed: "0 years, 3 days", "30 years, 0 days".
This is not nice and prevents from using this template in some places.
Please put instead: "3 days", "30 years".
Thanks.
Nnemo (talk) 23:08, 10 March 2011 (UTC)
replies: text: I disagree.  In the first case, I think that some people might like the year to make their templates line up. You can use  if you don't want to see the number of years.  In the second case, removing "0 days" makes it look like we are rounding down and losing a significant figure.  You can use  if you don't want to see number of days. —Arctic Gnome (talk • contribs) 02:18, 11 March 2011 (UTC)
replies: text: I would agree and disagree in part with each of the comments.  I don't believe that it's ever appropriate to write "0 years, 3 days".  If editors want their columns to line up, they can use align=right.  Using  is problematic for two reasons.  Firstly, as these templates are currently set up, using this template and either  or  will not give the correct sorting.  This can be fixed, of course (we could have them both sort by seconds (as  does)).  However, the second problem is not as easy to deal with; often the editor will not know whether there will be zero full years or not.  Suppose a minister is newly appointed, initially we'd use  but a year later we'd have to come back and change it to .  Not only would this be terribly inefficient but it's very likely that the editor won't come back to correct the mark up on the specific day in question.  I propose that the number of years be omitted if it's zero.  On the other hand, "0 days" is necessary for indicating precision as discussed above. Jimp 15:25, 8 April 2015 (UTC)
thread_title:  Edit request from Nnemo, 10 March 2011: Zero 

message: sandbox:
:
:
:
====Unexpected number error====
*
*
*
*
Problem reported at Template talk:Age in days. Fix needs to be made in , which is called by this template. – Wbm1058 (talk) 23:44, 13 February 2016 (UTC)
thread_title:  subst for debugging 

message: *
*
*
*
Problem reported at Template talk:Age in days. Fix needs to be made in , which is called by this template. – Wbm1058 (talk) 23:44, 13 February 2016 (UTC)
thread_title: Unexpected number error

message: :
:
----
Per my comment at Template talk:Age in days#Unexpected number error: spaces cause error message, I could make Module:Age work to replace this template as well, if wanted. Johnuniq (talk) 01:29, 14 February 2016 (UTC)
thread_title: other tests

message: When the result is about years and only one day, "years" is given in its singular form. That's what happens in World War II infobox: . Cheers.  Carlotm (talk) 18:57, 8 May 2015 (UTC)
replies: text: Sorry, I don't see any problem. Isn't "6 years and 1 day" correct? Wbm1058 (talk) 16:15, 13 February 2016 (UTC)

text: Oh, I see. Apparently this issue was fixed by this 21:24, 24 May 2015 edit to the subpage Template:Age in years and days/key. Wbm1058 (talk) 20:13, 13 February 2016 (UTC)
thread_title:  Singular / plural error 

message: Usually for extreme old people the  is used, because it's easier, especially for the dead people and there first anniversary of their birth hasn't passed yet since they died
For an example Tekla Juniewicz would've still been 116 if she were to still be alive as of 15 January 2023, however she would've been  years,  days though, when she died however on 19 August 2022 she was  years,  days, since the age of a dead person is permanent from when they died, there age does not increase after death
Age in years and days would seem more appropriate rather than just the age in years only especially for the people who died already and their first anniversary of their birth hasn't passed yet since they died which can be from 1 day to 1 year after they died.
Nabi Tajima would've still been 117 between 22 April 2018 and 3 August 2018 even if she was still alive, but the days would be from 261 to 364 rather than 260 days when she passed.
For people who died many many years ago such as George Washington when he died in December 1799 at the age of , if he was still alive today he would've been , the age in years and days wouldn't matter as much. 2603:6011:E00:4C41:0:0:0:1011 (talk) 19:28, 15 January 2023 (UTC)
thread_title:  Age in years and days should be often used in articles 

message: I was just reading an article on Maria Branyas. She was born on 4 March 1907. Today is March 1st. Using this template, it says that she is 115 years and 361 days.
On March 4th (3 days from now), she should be 116 years old, but 361 days + 3 is only 364.
Why is this off by a day? 2601:646:8400:C800:B7E9:CF81:2852:D240 (talk) 14:44, 1 March 2023 (UTC)
replies: text: 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. Johnuniq (talk) 05:59, 2 March 2023 (UTC)
thread_title:  Is calculation off by a day