Template talk:Birth year and age
![]() | This template does not require a rating on Wikipedia's content assessment scale. It is of interest to the following WikiProjects: | ||||||||||
|
Month option
[edit]I will be adding an optional second parmaeter so that the month can also be displayeed. Such as February 1950 (age 57–58). Sometimes the month is known just the day is missing. pete 15:46, 14 April 2008 (UTC)
- True. But you also need to adjust the calculation then. If I'd enter
{{birth year and age|1989|10}}
it shouldn't display "October 1989 (age 19–20)", but "October 1989 (age 19)" until September 30, and "October 1989 (age 20)" after that. --bender235 (talk) 23:46, 6 May 2009 (UTC)
{{editprotected}}
- I've created a new version of the template at {{Birth year and age/sandbox}}. As the template is fully protected, I've asked the administrator Wknight94 to substitute the old template with the new one. The new version does the following:
- If no birth month is stated, it displays "1980 (age 28–29)".
- If the birth month is less than the current month, it displays "1980 (age 28)".
- If the birth month is greater than the current month, it displays "1980 (age 29)".
- If the birth month is the same as the current month, it displays "1980 (age 28–29)". Both ages should appear, because since the day of birth is not stated it is not possible to determine whether the individual's birthday in the month has passed or not.
- I will update the documentation once the sandboxed template has been taken live. Aargh, guess {{Death year and age}} will need tweaking as well. — Cheers, JackLee –talk– 19:46, 8 May 2009 (UTC)
- I put the template in place (forgetting to remove the heading – but that's besides the point). Then I realized that it's backwards. Look at Wikipedia:Tutorial (External links)/sandbox – if someone was born in March 1970, they are 39 now, not 38. If they were born in October 1970, they are 38, not 39. I think you reversed > and < somewhere (but I'm about to go afk so I didn't look for a fix). Wknight94 talk 20:58, 8 May 2009 (UTC)
- Oops. OK, I've fixed the sandboxed template. — Cheers, JackLee –talk– 04:13, 9 May 2009 (UTC)
- Thanks, administrator MSGJ has implemented the updated template. — Cheers, JackLee –talk– 08:07, 9 May 2009 (UTC)
- I've created a new version of the template at {{Birth year and age/sandbox}}. As the template is fully protected, I've asked the administrator Wknight94 to substitute the old template with the new one. The new version does the following:
Typography
[edit]All documentation says it uses an n-dash, –, as a year range separator, but an hyphen-minus, -, is actually produced. Leandro GFC Dutra (talk) 14:48, 29 December 2010 (UTC)
- Click on the "View source" tab; you'll see that it uses the HTML character entity
–
which generates an en-dash, i.e. –. --Redrose64 (talk) 17:07, 29 December 2010 (UTC)
Edit request on 7 September 2012
[edit]![]() | This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
Please add a check for current date = 31 December (the last day of the year). In this case, it doesn't matter what month or day-month the person was born, we can explicitly determine their age in years as the simple difference between the current year and their birth year. Truthanado (talk) 10:27, 7 September 2012 (UTC)
Not done: This would be a fairly major change to the template, so it needs to be developed in the sandbox and tested before it goes up live. — Mr. Stradivarius (have a chat) 12:25, 7 September 2012 (UTC)
- It goes without saying that this would have to be tested in the sandbox. It shouldn't be such a major change to the template. The pseudo-code is:
- If CURRDATE = 31 December
- Then
- Display age as CURRYEAR - BIRTHYEAR
- Else
- <existing template code>
- EndIf
- I defer the implementation to someone much better at coding that I am. Thanks. Truthanado (talk) 02:22, 8 September 2012 (UTC)
- It goes without saying that this would have to be tested in the sandbox. It shouldn't be such a major change to the template. The pseudo-code is:
Birth year only
[edit]As far as I can tell, this is the only template can be used when only the birth year is known. However, the age calculation function isn't always needed. Can the template be modified to override the age display? Senator2029 ➔ “Talk” 04:10, 25 April 2014 (UTC)
- That, or another template for "Birth year". Since there is a "Birth date and age" and a "Birth date", there should be a "Birth year and age" and a "Birth year". But is this necessary for anything? I mean, I can just type the year normally, but do the templates help metadata or anything?—Msmarmalade (talk) 08:03, 2 July 2014 (UTC)
- {{Birth-year}} may be used for a year only date. Note the subtle use of a dash between birth and year!Periglio (talk) 18:58, 6 April 2015 (UTC)
Adding basic error checking to this template
[edit]I have added some basic error checking to the sandbox version of this template. See Template talk:Birth date and age and Template talk:Death date and age for previous discussions of this type of error checking.
The new code checks for month values that are less than 1 or greater than 12. It checks for years that are in the future, and for years that are more than 150 years in the past, since this template is supposed to be used only for living people.
Here are some examples of invalid dates that display an error message using the sandbox code:
- {{birth year and age/sandbox|1923|19}} → July 1923 (age 100) invalid month (invalid month)
- {{birth year and age/sandbox|1923|0}} → December 1923 (age 101) invalid month (invalid month)
- {{birth year and age/sandbox|2023}} → 2023 (age 0–1) (invalid year)
- {{birth year and age/sandbox|1723}} → 1723 (age 300–301) invalid year (invalid year – person is dead)
- {{birth year and age/sandbox|1923|9|30}} → September 1923 (age 100–101) (day included but ignored; no error message)
Comments are welcome. – Jonesey95 (talk) 03:17, 7 April 2015 (UTC)
- Thanks for doing this. I think the last one should say "Invalid parameter" as if they have a complete date, they should be using birth date and year. Periglio (talk)
- I have moved the error checking code from the sandbox to the template. I expect that we will see some articles appear in the error category soon. Please notify me if you see any problems with this change, and I will fix the template or revert the change.
- Since the extra parameters are not processed, I prefer not to call them an error at this time. If the extra parameters are present, the template behaves as documented and provides valid output. – Jonesey95 (talk) 20:07, 11 April 2015 (UTC)
- Zyxw has added error-checking that detects parameters other than two unnamed parameters. Pages are tracked in Category:Pages using birth year and age template with unknown parameters. The vast majority appear to be using
|df=
. – Jonesey95 (talk) 20:18, 19 September 2016 (UTC)
- Zyxw has added error-checking that detects parameters other than two unnamed parameters. Pages are tracked in Category:Pages using birth year and age template with unknown parameters. The vast majority appear to be using
Template-protected edit request on 23 January 2020
[edit]![]() | This edit request has been answered. Set the |answered= or |ans= parameter to no to reactivate your request. |
I would like to change this to place the articles that use this template into Category:X Births. Numberguy6 (talk) 20:47, 23 January 2020 (UTC)
Not done for now: please establish a consensus for this alteration before using the
{{edit template-protected}}
template. qedk (t 桜 c) 20:51, 23 January 2020 (UTC)- I'm not saying no, but WP:TEMPLATECAT recommends against it. Is this done by similar templates? – Jonesey95 (talk) 22:39, 23 January 2020 (UTC)
dash should be "or"
[edit]This currently reads "1967 (age 53–54)". But the dash usually indicates an inclusive interval, meaning the person is "53 through 54 years old". But the person isn't 53 through 54 years old: no one can be 53 through 54 years old: he's either 53 or 54 years old and we simply don't know which. The dash should be replaced by an "or". 195.192.229.9 (talk) 13:01, 14 July 2021 (UTC)
- It's a range, meaning "53 to 54". It is as accurate as we can be in a compact space, and it matches similar templates that use the same format. – Jonesey95 (talk) 17:20, 14 July 2021 (UTC)
- However on 31 December everyone has reached the birthday on that time, so maybe a definite age. Thingofme (talk) 00:21, 31 December 2022 (UTC)
Override ability for old dates being marked "invalid"
[edit]I am trying to use this template to refer to an individual animal (born in 1809, still living today). Understandably, the template thinks that 1809
is an invalid date; so, I would like there to be a way to manually override the "invalid date" display.
Example:
1809 (age 214–215) invalid year
.
Zhing'za zï Ïnin (talk) 21:42, 1 March 2023 (UTC)
- This template is intended for human ages. You can work around the error checking by using a different template, like this:
"1809 (age {{age in years|1809}})"
→ "1809 (age 214–215)"