Difference between revisions of "Template:Birthday"
(Created page with "<includeonly>{{#switch: {{str_find|{{{1}}}|年}}<!-- 检查生日是否带“年” --> | -1 = {{Ifnumber|{{{1}}}| {{#vardefine:生日日期| {{{1}}}月{{{2|1}}}日}} | {...") |
|||
Line 1: | Line 1: | ||
− | <includeonly>{{#switch: {{str_find|{{{1}}}| | + | <includeonly>{{#switch: {{str_find|{{{1}}}|}}<!-- 检查生日是否带“年” --> |
− | | -1 = {{Ifnumber|{{{1}}}| {{#vardefine: | + | | -1 = {{Ifnumber|{{{1}}}| {{#vardefine:birthdate| {{{1}}}月{{{2|1}}}日}} | {{#vardefine:birthdate|{{{1}}}}}<!-- 不含“年”字,不改变输入内容 -->}} |
− | | {{#vardefine: | + | | {{#vardefine:birthdate<!-- 如果含“年” --> |
− | |{{str_right|{{{1}}}|{{str_find|{{{1}}}| | + | |{{str_right|{{{1}}}|{{str_find|{{{1}}}|}}}} |
}}<!-- 定义“生日日期”为“年”字右边的字符 --> | }}<!-- 定义“生日日期”为“年”字右边的字符 --> | ||
− | {{#vardefine: | + | {{#vardefine:birthyear |
− | |{{str_left|{{{1}}}|{{str_find|{{{1}}}| | + | |{{str_left|{{{1}}}|{{str_find|{{{1}}}|}}}} |
}}<!-- 定义“生日年份”为“年”字及左边的字符 --> | }}<!-- 定义“生日年份”为“年”字及左边的字符 --> | ||
}}<!-- End Switch | }}<!-- End Switch | ||
− | -->{{#vardefine: | + | -->{{#vardefine:birthcat |
|{{#if:{{{1|}}}<!-- 如果填写了生日 --> | |{{#if:{{{1|}}}<!-- 如果填写了生日 --> | ||
− | |{{#switch: {{str_find|{{#var: | + | |{{#switch: {{str_find|{{#var:birthdate}}|}}<!-- 检查“月”字是否出现在第2或第3个字符位置 --> |
| 2 | | 2 | ||
− | | 3 = {{#if: {{str_endswith|{{#var: | + | | 3 = {{#if: {{str_endswith|{{#var:birthdate}}|}}<!-- 检查“日”字是否出现在最后1个位置 --> |
− | | {{#var: | + | | {{#var:birthyear}}[[:Category:{{#var:birthdate}}|{{#var:birthdate}}]]{{ArticleCategory|{{#var:生日日期}}}}<!-- 符合要求,显示日期分类(年份不带分类内链) --> |
− | | {{#if: {{str_endswith|{{#var: | + | | {{#if: {{str_endswith|{{#var:birthdate}}|}}<!-- 容错:检查最后1个字符是否为“号” --> |
− | | {{#var: | + | | {{#var:birthyear}}[[:Category:{{Str_crop|{{#var:birthdate}}|1}}|{{#var:birthdate}}]][[Category:{{Str_crop|{{#var:birthdate}}|1}}日]]<!-- 是,则在分类中将“号”改为“日” --> |
− | |{{{1}}}{{#if:{{{ft|}}}||{{ArticleCategory| | + | |{{{1}}}{{#if:{{{ft|}}}||{{ArticleCategory|Incorrect birthday}}}}<!-- 不符合“号”字要求,显示“错误生日” --> |
}} | }} | ||
}} | }} | ||
− | |{{{1}}}{{#if:{{{ft|}}}||{{ArticleCategory| | + | |{{{1}}}{{#if:{{{ft|}}}||{{ArticleCategory|Incorrect birthday}}}}<!-- 不符合“月”字要求,显示“错误生日” --> |
}}<!-- End Switch --> | }}<!-- End Switch --> | ||
|}}<!-- 没有填写生日 --> | |}}<!-- 没有填写生日 --> | ||
}}<!-- End Vardefine | }}<!-- End Vardefine | ||
− | -->{{#var: | + | -->{{#var:birthcat}}</includeonly><noinclude>{{Documentation}}[[Category:Auxiliary templates]]</noinclude> |
Revision as of 23:56, 19 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