Difference between revisions of "Template:Birthday"
Line 1: | Line 1: | ||
− | <includeonly>{{#switch: {{str_find|{{{1}}}|}}<!-- | + | <includeonly>{{#switch: {{str_find|{{{1}}}|}}<!-- Check if the birthday contains the year --> |
− | | -1 = {{Ifnumber|{{{1}}}| {{#vardefine:birthdate| {{{1}}}月{{{2|1}}}日}} | {{#vardefine:birthdate|{{{1}}}}}<!-- | + | | -1 = {{Ifnumber|{{{1}}}| {{#vardefine:birthdate| {{{1}}}月{{{2|1}}}日}} | {{#vardefine:birthdate|{{{1}}}}}<!-- If there is no year, don't change the input content -->}} |
− | | {{#vardefine:birthdate<!-- | + | | {{#vardefine:birthdate<!-- If it contains the year --> |
|{{str_right|{{{1}}}|{{str_find|{{{1}}}|}}}} | |{{str_right|{{{1}}}|{{str_find|{{{1}}}|}}}} | ||
− | }}<!-- | + | }}<!-- Define "birthdate" as the characters to the right of the year --> |
{{#vardefine:birthyear | {{#vardefine:birthyear | ||
|{{str_left|{{{1}}}|{{str_find|{{{1}}}|}}}} | |{{str_left|{{{1}}}|{{str_find|{{{1}}}|}}}} | ||
− | }}<!-- | + | }}<!-- Define "birthyear" as the characters to the left of the birthdate --> |
}}<!-- End Switch | }}<!-- End Switch | ||
-->{{#vardefine:birthcat | -->{{#vardefine:birthcat | ||
− | |{{#if:{{{1|}}}<!-- | + | |{{#if:{{{1|}}}<!-- If you fill in the birthday --> |
− | |{{#switch: {{str_find|{{#var:birthdate}}|}}<!-- | + | |{{#switch: {{str_find|{{#var:birthdate}}|}}<!-- Check whether the month appears in the parameter 2 or 3 --> |
| 2 | | 2 | ||
− | | 3 = {{#if: {{str_endswith|{{#var:birthdate}}|}}<!-- | + | | 3 = {{#if: {{str_endswith|{{#var:birthdate}}|}}<!-- Check whether the day appears in the last parameter --> |
− | | {{#var:birthyear}}[[:Category:{{#var:birthdate}}|{{#var:birthdate}}]]{{ArticleCategory|{{#var: | + | | {{#var:birthyear}}[[:Category:{{#var:birthdate}}|{{#var:birthdate}}]]{{ArticleCategory|{{#var:birthdate}}}}<!-- If it meets the requirements, it shows the date category (Year without category internal link) --> |
| {{#if: {{str_endswith|{{#var:birthdate}}|}}<!-- 容错:检查最后1个字符是否为“号” --> | | {{#if: {{str_endswith|{{#var:birthdate}}|}}<!-- 容错:检查最后1个字符是否为“号” --> | ||
− | | {{#var:birthyear}}[[:Category:{{Str_crop|{{#var:birthdate}}|1}}|{{#var:birthdate}}]][[Category:{{Str_crop|{{#var:birthdate}}|1}} | + | | {{#var:birthyear}}[[:Category:{{Str_crop|{{#var:birthdate}}|1}}|{{#var:birthdate}}]][[Category:{{Str_crop|{{#var:birthdate}}|1}}]]<!-- 是,则在分类中将“号”改为“日” --> |
− | |{{{1}}}{{#if:{{{ft|}}}||{{ArticleCategory|Incorrect birthday}}}}<!-- | + | |{{{1}}}{{#if:{{{ft|}}}||{{ArticleCategory|Incorrect birthday}}}}<!-- If this does not meet the requirements, "Incorrect birthday" is displayed--> |
}} | }} | ||
}} | }} | ||
− | |{{{1}}}{{#if:{{{ft|}}}||{{ArticleCategory|Incorrect birthday}}}}<!-- | + | |{{{1}}}{{#if:{{{ft|}}}||{{ArticleCategory|Incorrect birthday}}}}<!-- If the month does not meet the requirements, "Incorrect birthday" is displayed --> |
}}<!-- End Switch --> | }}<!-- End Switch --> | ||
− | |}}<!-- | + | |}}<!-- No birthday filled in --> |
}}<!-- End Vardefine | }}<!-- End Vardefine | ||
-->{{#var:birthcat}}</includeonly><noinclude>{{Documentation}}[[Category:Auxiliary templates]]</noinclude> | -->{{#var:birthcat}}</includeonly><noinclude>{{Documentation}}[[Category:Auxiliary templates]]</noinclude> |
Revision as of 00:18, 20 September 2023
This is an auxiliary template for birthday projects for [Characterinfo] and other related templates.
The purpose is to automatically identify and generate birthday categories. Incorrect birthday pages can be found in the Category:Incorrect birthday. If you don't want to display the incorrect birthday category, you can invoke the fault tolerance by adding the parameter value ft=true, or don't use this template, and use the "Special birthday" parameter in [Characterinfo] instead.
Usage instructions
1, {{Birthday|June 30}}
June 30
2, {{Birthday|December 1, 1998}}
December 1, 1998
3, {{Birthday|4|25}}
4
Related templates
- {{hair color}}: For hair colors
- {{eye color}}: For eye colors
- {{age}}: For the age
- {{horoscope}}: For the zodiac sign