Template talk:Age in years and days
This template does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||
|
Leap years
[edit]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: 1 year, 1 dayFor 1995-6: 1 year, 2 daysFor 1996-7: 1 year, 1 day
I think I've found a way to fix it. --Arctic Gnome (talk • contribs) 23:11, 17 July 2007 (UTC)
- 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)
- 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)
- Thanks and well done Arctic.gnome. —Moondyne 01:38, 18 July 2007 (UTC)
- 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)
- Thanks and well done Arctic.gnome. —Moondyne 01:38, 18 July 2007 (UTC)
- 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)
Protected
[edit]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)
- Actually, it was User:Hesperian who created it [1] on my request. He gets the credit. —Moondyne 07:46, 20 July 2007 (UTC)
Invalid dates
[edit]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))
- 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: {{age}} and {{age in days}} 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)
- 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))
- 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)
- 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))
- 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)
- 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)
- 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: {{age}} and {{age in days}}. 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)
- I added some documentation at Template:Age/doc about wrong input.--Patrick 06:20, 9 August 2007 (UTC)
- 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))
- 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))
- 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))
- I added some documentation at Template:Age/doc about wrong input.--Patrick 06:20, 9 August 2007 (UTC)
- 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: {{age}} and {{age in days}}. 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)
- 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))
Commas
[edit]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)
- 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))
- 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)
- 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)
- 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))
Greetings,
This seems to be an issue of style. Newspapers and book publications (including Guinness World Records) do NOT use commas for age (or the use of 'and'). The main reason is to save printing space (lowering cost and increasing efficienty, important with books that have to cut some material to meet a page limit). However, it has an added benefit: efficiency for the reader. One can read the age 'faster' without the , because one's mind has been trained to slow down when it sees a comma (like a 'yellow light' on the information superhighway). Further, it seems the best example of why 'not' to use them is the one you cited: 73 years, 4 months, and 16 days. It sounds like reading a novel. It is also old-fashioned and technically incorrect. Why? Because some months have 31 days; some have 30 days; February has 28 or 29 days. Comparing ages, then, requires the use of a 'day' counter, without 'months'...a 'day' is always the same for everyone. It makes sense to use commas for a novel but not for tables/graphs/mathematical formulas/etc. Note that using a comma could mess up an 'Excel' formula calculation.
The last reason is that the , implies movement, but most of the people on the longevity lists are dead and the age isn't going to change. Thus, it looks a bit visually distracting to have it there. It's a minor issue but in the long run, efficiency and readability argue for 'no commas' when an age is given in a table format.
However, this need not be an either/or proposition: perhaps two versions could be made (one with a comma and one without). The comma is better for use with the 'written word'/dialogue. Just an idea.
Sincerely, Robert Young Ryoung122 06:58, 10 August 2007 (UTC)
- 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)
I think that we should keep the commas as per Joseph. It seems grammatically correct to have a comma there, and since this will mostly be used in lists, I do not foresee a problem with the flow and pacing of the text being slowed. --Arctic Gnome (talk • contribs) 14:27, 10 August 2007 (UTC)
- 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)
- 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)
Missing protection template
[edit]{{editprotected}}
Someone needs to add the {{Protected template}} 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)
- Done. — Carl (CBM · talk) 00:05, 22 August 2007 (UTC)
- Thanks. (Joseph A. Spadaro 00:24, 24 August 2007 (UTC))
Infant age
[edit]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)
- 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)
Years, months, days
[edit]Is there a template for calculating age in Years, months, and days?—Markles 00:02, 3 December 2007 (UTC)
- 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)
Too many on one page?
[edit]There reached a point on List of living former United States Senators where the templates information does not appear. Is there a reason for this? When it starts this, it says "Expression error: Unexpected < operator". (Star Garnet 19:30, 15 December 2007 (UTC))
- That is very odd, the system just doesn't want to process templates after a certain number of them. I can't think of anything on this template that would cause that; you may have to talk to people who know more about how the wiki-system as a whole processes information. --Arctic Gnome (talk • contribs) 20:19, 15 December 2007 (UTC)
- I've seen this problem before. It seems to be a temporary problem with MediaWiki, not the page or the template. Sit back and relax. It should fix itself… I hope.—Markles 20:32, 15 December 2007 (UTC)
- Due to the pre-expand include size maximum of 2,048,000 bytes you can only call this template a little more than 100 times on a page.--Patrick (talk) 23:58, 15 December 2007 (UTC)
- Well, then we're screwed. Can anyone create a work-around?—Markles 01:12, 16 December 2007 (UTC)
- The {{age in days}} template has been changed so that it no longer needs to have parameters like "year1=" in it, meaning I can make the code for this template
muchsmaller. Maybe that would help. --Arctic Gnome (talk • contribs) 02:01, 16 December 2007 (UTC) - Okay, so I was not able to shorten it as much as I hoped, I've allowed for one extra calculation per page. It takes up a lot of space to make this template subtract the total years from the {{age in days}} template. I think your best bet is to just list their ages by years rather than giving the exact number of days. For people who have passed on, you can subst: this template and fit many more numbers into an article.
- I've found another way to make it have to do a bit less processing, but now it will use plurals when it shouldn't on January 1st and February 29th, giving "1 days" rather than "1 day". I don't think having bad grammar every few years is worth getting two extra usages per page. --Arctic Gnome (talk • contribs) 03:06, 16 December 2007 (UTC)
- I made an adjustment so that the number of days is computed only once, now the capacity is 1.5 times what is currently on List of living former United States Senators.--Patrick (talk) 09:44, 16 December 2007 (UTC)
- A subpage? Very clever, I'm impressed. --Arctic Gnome (talk • contribs) 19:55, 16 December 2007 (UTC)
- I made an adjustment so that the number of days is computed only once, now the capacity is 1.5 times what is currently on List of living former United States Senators.--Patrick (talk) 09:44, 16 December 2007 (UTC)
- The {{age in days}} template has been changed so that it no longer needs to have parameters like "year1=" in it, meaning I can make the code for this template
- Well, then we're screwed. Can anyone create a work-around?—Markles 01:12, 16 December 2007 (UTC)
- Due to the pre-expand include size maximum of 2,048,000 bytes you can only call this template a little more than 100 times on a page.--Patrick (talk) 23:58, 15 December 2007 (UTC)
- I've seen this problem before. It seems to be a temporary problem with MediaWiki, not the page or the template. Sit back and relax. It should fix itself… I hope.—Markles 20:32, 15 December 2007 (UTC)
Browser-Dependent??!?
[edit]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)
- 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)
elapsed time
[edit]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 {{For year month day}}, however, it apparently cannot handle the future. --emerson7 17:31, 13 December 2008 (UTC)
This seems to be causing problems for Google
[edit]"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)
A year wrong
[edit]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)
- Use year1|month1|day1.--Patrick (talk) 23:30, 5 October 2010 (UTC)
Edit request from Nnemo, 10 March 2011: Singular
[edit]{{edit protected}}
When the number is 0, plural is displayed: "0 years, 3 days", "30 years, 0 days". This is incorrect. Please put singular instead: "0 year, 3 days", "30 years, 0 day".
Thanks.
Nnemo (talk) 22:57, 10 March 2011 (UTC)
- I would disagree with this. Are you a native English speaker? Zero is normally used with the plural - it's only 1 which uses the singular. — Martin (MSGJ · talk) 23:11, 10 March 2011 (UTC)
- That would be illogical. Do you have a source such as a dictionary?
- I am not a native anglophone.
- In my native language: 0, 0.5, 1, 1.9 are singular, and plural starts at 2.
- Nnemo (talk) 01:29, 11 March 2011 (UTC)
- Not done: I am a native English speaker, and I always see plurals for every number except 1 (and maybe -1). Our article Plural#Zero discusses the relationship between plurals and zero. —Arctic Gnome (talk • contribs) 02:12, 11 March 2011 (UTC)
Edit request from Nnemo, 10 March 2011: Zero
[edit]{{edit protected}}
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)
- I disagree. In the first case, I think that some people might like the year to make their templates line up. You can use {{age in days}} 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 {{age in years}} if you don't want to see number of days. —Arctic Gnome (talk • contribs) 02:18, 11 March 2011 (UTC)
- 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 {{age in days}} is problematic for two reasons. Firstly, as these templates are currently set up, using this template and either {{age in days}} or {{age in days nts}} will not give the correct sorting. This can be fixed, of course (we could have them both sort by seconds (as {{val}} 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 {{age in days}} but a year later we'd have to come back and change it to {{age in years and days}}. 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)
- 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
Edit request from Nnemo, 10 March 2011: Non-breaking space
[edit]{{edit protected}}
Is displayed: "30 years, 20 days".
In some places, the line gets cut just after the number: this is bad typography and so prevents from using this template. See Wikipedia:Line break handling, MOS:NBSP, Wikipedia:Manual of Style (dates and numbers)#Non-breaking spaces.
Please put instead: "30 years, 20 days".
Thanks.
Nnemo (talk) 23:58, 10 March 2011 (UTC)
- Done —Arctic Gnome (talk • contribs) 02:09, 11 March 2011 (UTC)
- I mean:
- Please put instead: "30 years, 20 days".
- Nnemo (talk) 02:21, 11 March 2011 (UTC)
- Is it not doing that? It's working for me. Have you tried refreshing? —Arctic Gnome (talk • contribs) 02:25, 11 March 2011 (UTC)
Spaces cause error message
[edit]The first of these currently gives a bunch of ugly error messages due to a space (see source):
- 1 year, 4 days
- 1 year, 4 days
- 1 year, 4 days
It was reported at Wikipedia:Village pump (technical)/Archive 136#An old problem in a table. PrimeHunter (talk) 01:36, 11 April 2015 (UTC)
- Well, that's interesting. I thought that leading and trailing spaces in template parameters were always trimmed. I suppose that this must be because parser-function parsing doesn't trim spaces, unlike template-parameter parsing.
{{Age in years and days|2007|02|27|2008|03| 2}}
{{Age in years and days|2007|02|27|2008|03|2}}
{{Age in years and days|2007|02|27|2008|03|02}}
- - Wbm1058 (talk) 15:49, 13 February 2016 (UTC)
subst for debugging
[edit]sandbox:
- 1 year, 4 days
- 1 year, 4 days
- 1 year, 4 days
Unexpected number error
[edit]{{age in days|{{#ifexpr:03<02|{{#expr:2008-1}}|{{#ifexpr:03=02|{{#ifexpr: 2<27|{{#expr:2008-1}}|2008}}|2008}}}}|02|27|2008|03| 2}}
- 4
{{age in days|{{#ifexpr:03<02|{{#expr:2008-1}}|{{#ifexpr:03=02|{{#ifexpr: 2<27|{{#expr:2008-1}}|2008}}|2008}}}}|02|27|2008|03|2}}
- 4
Problem reported at Template talk:Age in days. Fix needs to be made in {{Age in days}}, which is called by this template. – Wbm1058 (talk) 23:44, 13 February 2016 (UTC)
other tests
[edit]- 1 year, 4 days
- 1 year, 4 days
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)
Singular / plural error
[edit]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: 6 years, 1 day. Cheers. Carlotm (talk) 18:57, 8 May 2015 (UTC)
- Sorry, I don't see any problem. Isn't "6 years and 1 day" correct? Wbm1058 (talk) 16:15, 13 February 2016 (UTC)
- 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)
Google problems
[edit]As noted 7 years ago but still the case - ""at the age of &0000000000000113.000000113 years, &0000000000000041.00000041" - is this Google's fault, or is it somethign we can improve?".
The issue is that this template always introduces a sort key, hidden by inline CSS, before the age; which is picked up by Google, and therefore pollutes the data displayed on Google's preview. I noticed this when searching for Emma Morano-Martinuzzi, the new oldest woman in the world, in the news at the moment - searching for her gives a Google summary of "Emma Martina Luigia Morano Martinuzzi (born 29 November 1899) is an Italian supercentenarian who is, at the age of 7009367502400000000♤116 years, 166 ...".
Any thoughts? The ideal would be a parameter or subtemplate to only include the NTS info when actually required; I suspect that, with this being used in so many places, what we might actually have to do is add a parameter or subtemplate to *exclude* the NTS info; unless someone could use a bot to go through and replace every instance which is in a sortable table with an alternative template. TSP (talk) 14:40, 13 May 2016 (UTC)
- To show the issue, the following is from Walter Breuning:
{{age in years and days|1896|9|21|2011|4|14}}
→ 114 years, 205 days
- Using Special:ExpandTemplates shows the template output is:
<span style="display:none" class="sortkey">7009361527840000000♠</span>114 years, 205 days
- I do not see the problem when clicking the Google search link in the OP. Does it still appear for you? I do see the problem when searching for "Emma Martina Luigia Morano Martinuzzi".
- It might be worth asking about the problem at WP:VPT.
- The {{val}} template does a similar thing of always outputting a hidden sort key as a convenience for when it is used in a sortable table. I have wondered whether another template, say vals, could conveniently provide a sort key, while plain val would not output clutter. The "pure" method of requiring a parameter like
|sortable=on
is ugly. By the way, per my comment above on this page, it would be possible to replace this template with a module that is under development. Johnuniq (talk) 00:07, 14 May 2016 (UTC)- FYI, Wikipedia:Village pump (technical)/Archive 145#"Under Title" issue. --Edgars2007 (talk/contribs) 07:54, 14 May 2016 (UTC)
- Interesting, what a mess! Johnuniq (talk) 10:00, 14 May 2016 (UTC)
- Johnuniq: No, it no longer seems to be used in the intro to the Walter Breuning page, perhaps because Breuning is now dead; but the issue whn searching for Emma Martinuzzi is exactly the same one raised 7 years ago. TSP (talk) 21:40, 14 May 2016 (UTC)
- I see that the similar template Template:Age in days has an alternative Template:Age in days nts for cases where sorting is required. I would suggest that we adopt the same solution here for consistency, unless someone feels strongly that a different one is better. TSP (talk) 21:45, 14 May 2016 (UTC)
- And still a problem. I do indeed suggest we go with TSP's solution. —TheDJ (talk • contribs) 09:27, 21 April 2017 (UTC)
- See #Propose using Module:Age below. I just tried seeing the Google problem and could not find an example, however if it is still an issue, the solution requires that this template be changed so that no hidden sort key is produced. We need to first work out if any occurrences need that sort key! Using the module would be best because the age calculations would not be duplicated between two templates. If you agree, please comment below and I can implement it soon. Johnuniq (talk) 11:38, 21 April 2017 (UTC)
- And still a problem. I do indeed suggest we go with TSP's solution. —TheDJ (talk • contribs) 09:27, 21 April 2017 (UTC)
- Interesting, what a mess! Johnuniq (talk) 10:00, 14 May 2016 (UTC)
- FYI, Wikipedia:Village pump (technical)/Archive 145#"Under Title" issue. --Edgars2007 (talk/contribs) 07:54, 14 May 2016 (UTC)
@TheDJ: I changed Module:Age so {{age in years and days/sandbox}} does not add a sort key, and created {{age in years and days nts}} to include the sort key. The sandbox template could be used to replace the main template when we think it is ok to switch sorting off. I found {{ayd}} which was a redirect to the current template, and changed it to redirect to {{age in years and days nts}} because {{ayd}} is used in tables of sortable durations. Johnuniq (talk) 09:32, 22 April 2017 (UTC)
Propose using Module:Age
[edit]Module:Age implements a lot date/time functions, and it can emulate this template. To demonstrate, I changed {{age in years and days/sandbox}} to use the module. Examining the testcases shows these differences.
Update: In the following, the results for {{age in years and days}} use fixed wikitext to show output from the old template. Johnuniq (talk) 02:05, 6 May 2017 (UTC)
Difference #1
{{age in years and days|2004|2|29|2006|3|01}}
→ 2 years, 0 days{{age in years and days/sandbox|2004|2|29|2006|3|01}}
→ 2 years, 1 day- timeanddate.com says "Or 2 years, 1 day excluding the end date"
Difference #2
{{age in years and days|1 Mar 2004|28 Feb 2002}}
→ −2 years, 2 days{{age in years and days/sandbox|1 Mar 2004|28 Feb 2002}}
→ −2 years, 2 days{{age in years and days|2004|3|1|2002|2|28}}
→ -3 years, 364 days (not the wanted values, and uses a hyphen for negative){{age in years and days/sandbox|2004|3|1|2002|2|28}}
→ −2 years, 2 days
Difference #3 A space in an unexpected place causes an error in the existing template (see #Spaces cause error message above).
{{age in years and days|2007|2|1|2008|3| 1}}
→ (An error message was displayed by the old template){{age in years and days/sandbox|2007|2|1|2008|3| 1}}
→ 1 year, 29 days
This is prompted by #Google problems above where it is proposed that the template be switched to sortable=off rather than the default, which is to include a hidden sort key before the result. Currently the module emulates the template including the fact that sortable=on is the default. It would be easy to change that default, or do anything else needed. Johnuniq (talk) 11:29, 21 April 2017 (UTC)
- I have updated the template to use the module. Currently sortable=on is used for compatibility with the old template. For cases where a sortable key is wanted, {{ayd}} (which redirects to {{age in years and days nts}}) can be used. When articles using the template have been checked and adjusted as required, the module can be changed so sortable=off will apply. Johnuniq (talk) 11:20, 4 May 2017 (UTC)
2605:A000:1103:144:251E:BE4:FF27:D0B8 (talk) 19:46, 18 November 2018 (UTC)== Using mm/dd/yyyy format for calculations ==
{{age in years and days|08/16/2016|07/24/2018}} gives Error: Need valid year, month, day results in an error, why? — Preceding unsigned comment added by 2605:a000:1103:c3:e8b6:2374:8937:4e50 (talk • contribs) 14:17, 23 September 2018 (UTC)
- Those particular dates can be parsed as being mm/dd/yyyy because 16 and 24 are not valid months. However, the template rejects attempts to use that format because lots of people expect a date like that to be dd/mm/yyyy. The template requires non-ambiguous formats such as:
{{age in years and days|2016-08-16|2018-07-24}}
→ 1 year, 342 days{{age in years and days|16 Aug 2016|24 July 2018}}
→ 1 year, 342 days
- Johnuniq (talk) 23:32, 23 September 2018 (UTC)
{{date|08/16/2016}} gives 16 August 2016 and the format works on the date template — Preceding unsigned comment added by 2600:1:b1a6:97c5:b53a:2108:a250:3651 (talk • contribs) 13:01, 24 September 2018 (UTC)
- We have had this discussion before although I forget where. Please do not use ambiguous date formats because they will confuse some people and lead to incorrect results. Johnuniq (talk) 23:50, 24 September 2018 (UTC)
Well, {{date|08/16/2016}}
works perfectly, why do not use it then?, well 08/16/2016 can be parsed as 16 August 2016, because there is no 16th month.
Offset in the calculation between dates
[edit]@Johnuniq Is it possible to display the duration between two dates with an offset (eg., minus 10 days, plus 15 days, etc.):
age in years and days|1 January 2017|1 January 2018 is expressed as 1 year, 0 days
age in years and days|date 1|date 2|parameter to add/subtract a duration is what I'm looking for.
If it's not possible, does another wiki template exist which can perform this? 156.196.150.85 (talk) 22:44, 31 October 2018 (UTC)
- I think some existing template and/or parser functions allow date arithmetic. The templates which use Module:Age can do this in a somewhat round-about way. See Template:Extract#Add for documentation on adding or subtracting offsets from a date. The idea is to use {{extract}} to return a modified date which is then passed to whichever age template is wanted.
{{age in years and days|1 January 2017|1 January 2018}}
→ 1 year, 0 days{{age in years and days|1 January 2017|{{extract|1 January 2018|add=-10d}}}}
→ 355 days{{age in years and days|1 January 2017|{{extract|1 January 2018|add=15d}}}}
→ 1 year, 15 days{{age in years and days|1 January 2017|{{extract|1 January 2018|add=3m 15d}}}}
→ 1 year, 105 days
- Johnuniq (talk) 00:06, 1 November 2018 (UTC)
- Brilliant! Thank you Johnuniq. 156.196.150.85 (talk) 00:18, 1 November 2018 (UTC)
When the year is not a leap year, will give errors when there is no February 29th
[edit]Here is an example, when it's not a leap year and there's no February 29th, it will return as an error
{{age in years and days|1900|8|4|2018|2|29}}
- Error: Second date should be year, month, day will produce an error message why? (expected 117 years, 209 days), it should be corrected such like {{age in years and days|{{date|08/04/1900}}|{{date|02/29/2018}}}}
{{age in years and days|{{date|08/04/1900}}|{{date|02/29/2018}}}}
will be corrected as 117 years, 209 days
{{age in years and days|1900|8|4|2018|3|1}}
- age on 1 March 2018 will give 117 years, 209 days — Preceding unsigned comment added by 98.31.29.4 (talk)
- February 29 in a non-leap year is an invalid date and is the example of the error message at Template:Age in years and days#Usage. It makes good sense to produce an error message for invalid dates. It should be corrected by giving a valid date and not by using a template which accepts invalid dates.
{{date|02/29/2018}}
produces 1 March 2018 per Template:Date#Known issues. PrimeHunter (talk) 00:26, 20 February 2019 (UTC)
Also bugged with Feb 29 births, such as 118 years, 1 day (expected 118 years, 0 days) KaiHunter12 (talk) 21:18, 24 June 2022 (UTC)
- The example above is:
{{ayd|1904|2|29|2022|3|1}}
→ 118 years, 1 day
- That is not a bug, it's a side-effect of having an irregular calendar. The following is a good website: https://www.timeanddate.com/date/durationresult.html?y1=1904&m1=2&d1=29&y2=2022&m2=3&d2=1
- It gives the result:
It is 43,100 days from the start date to the end date, but not including the end date. Or 118 years, 1 day excluding the end date.
Johnuniq (talk) 23:52, 24 June 2022 (UTC)
Age in years and days should be often used in articles
[edit]Usually for extreme old people the {{age in years and days}}
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 118 years, 164 days though, when she died however on 19 August 2022 she was 116 years, 70 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 67, if he was still alive today he would've been 292, 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)
Is calculation off by a day
[edit]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)
- 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)
Subtracting average ages
[edit]Hello.
I am trying to calculate the difference in average ages. For example, the average age of a football squad this year is 27 years and 10 days as of today. The average age of a football squad last year was 26 days and 350 days as of 30 June 2024.
How can I calculate the difference which then moves as each day passes (for example, today, the difference in the example is 20 days. But tomorrow that will be 21 days, the day after 22 days etc.)
Many thanks! 79.78.124.80 (talk) 09:18, 11 October 2024 (UTC)
- Are you aware that pages are cached so just viewing an article won't generally update a template which displays the result of a calculation? See the section just before this (#Is calculation off by a day) for a little more. Regarding the problem, can you post an example of the wikitext for a hypothetical template which did what you wanted? Just use single {...} braces, not double. In other words, I'm asking what inputs would be given to a template. You want the number of days difference as the output. Johnuniq (talk) 09:39, 11 October 2024 (UTC)