Template talk:Lifespan
Logic
[edit]Version 1
[edit]- Check brackets; if default (parentheses around full output) display opening bracket
- If the birth or death parameter is missing or empty, display error message, categorize the page, and proceed to closing bracket check
- Else (birth+death exist and not empty), if error checking (parameter err) is on, display any non-date parameter error messages and maintenance notices; continue
- Display optional content label ("lifespan: "). If parameter 'Prefix' exists suppress label; display error message if error-checking is on; continue
- Display optional birth prefix
- Display optional circa for birth (or for both birth & death)
- Display birth year or, if requirements/constraints are ignored display error message(s) and categorize the page; continue
- Display optional alternative birth year or, if requirements/constraints are ignored display error message(s) and categorize the page; continue
- Display optional 1st suffix to indicate era straddle (BC-AD or BCE-CE)
- Display date span separator per MOS:YEAR and MOS:YEARRANGE
- If prefixes are used, display the death prefix
- Display optional circa for death (or both birth & death)
- Display death year or, if requirements/constraints are ignored display error message(s) and categorize the page; continue
- Display optional alternative death year or, if requirements/constraints are ignored display error message(s) and categorize the page; continue
- Display optional date-span suffix (implied default is AD/CE, BC-AD and BCE-CE notations are functionally identical) or the 2nd suffix of era straddle
- Error-check date parameters relative to their suffix; display any error messages; continue
- If age range is processed:
- Check brackets: if around age only, disregard full-output bracket, add space and open age bracket; else add comma & space
- Check age label (default is "aged")
- If it exists, pass circa to the age range
- If there are alternative years, calculate & display age range(s) relative to birth/death configuration, and the suffix; else only consider the suffix to calculate & display range, after checking whether birth and death occurred in the same year
- Add trailing static text "years"
- If age in years is processed instead:
- Check brackets as in age range above
- Check age label
- If it exists, pass circa to the age
- Check whether birth and death occurred in the same year and display static text if so; else calculate & display the age considering the birthday (relative to death date), and the suffix
- Add trailing static text "years"
- End else (birth+death exist and not empty)
- If brackets are not removed, display closing bracket and exit, else exit
The category Category:Template Lifespan errors must be created before errors are trapped. It is commented out in code and fake-linked in the doc (and here). 172.254.202.90 (talk) 01:50, 20 December 2024 (UTC)
- Edit revision to reflect current doc changes; no code edits.65.88.88.216 (talk) 20:22, 20 December 2024 (UTC)
Version 1.0.1
[edit]Added prefix options to display abbreviations with or without tooltips; retained previous option for compatibility (undocumented).
Version 1.0.1a
[edit]Code: Added message for parameter ca error condition (uses temp param {{{YV}}}).
Doc: Added example re:above. 98.7.84.118 (talk) 14:47, 26 December 2024 (UTC)
Version 1.0.1b
[edit]Code: Simplified error condition (removed temp param {{{YV}}}); added error messages to age component; trapped related expression errors with null message. 50.75.226.250 (talk) 22:47, 26 December 2024 (UTC)
Version 1.0.2
[edit]Code: Trapped some errors re: era straddles. 68.174.124.254 (talk) 22:05, 31 December 2024 (UTC)
Version 1.0.3
[edit]Code (not optimized special case): Year 0 (zero) handling as an optional error or maintenance condition.
Doc: Sync with code, updated with example, etc.
Version 1.0.3a
[edit]Code: minor copyedit, year 0 maintenance notice. 72.106.120.184 (talk) 18:50, 1 January 2025 (UTC)
Version 1.0.3b
[edit]Code: rm superfluous error case (flagged elsewhere); etc. 98.7.84.118 (talk) 13:28, 2 January 2025 (UTC)
Version 1.0.3d
[edit]Revision (partial revert to revision below)
Code: year 0 handling minor optimizations, rm superfluous case flagged elsewhere, add cases. 69.200.249.191 (talk) 17:02, 6 January 2025 (UTC)
- had to roll back a section update as it omitted several cases. 65.88.88.70 (talk) 22:10, 6 January 2025 (UTC)
Version 1.0.3e
[edit]Code: minor simplifications. 104.247.55.106 (talk) 02:01, 7 January 2025 (UTC)
- updated revision to reflect comments. 98.7.84.118 (talk) 15:14, 7 January 2025 (UTC)