More actions
No edit summary |
No edit summary |
||
| (3 intermediate revisions by the same user not shown) | |||
| Line 3: | Line 3: | ||
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | <!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) --> | ||
{{for|the article header for year articles|Template:Year article header}} | {{for|the article header for year articles|Template:Year article header}} | ||
== Usage == | == Usage == | ||
{{Tlx|YEAR|{{var|string formatted as a valid date}}}} | {{Tlx|YEAR|{{var|string formatted as a valid date}}}} | ||
Specify optional parameter | Specify optional parameter to get soft error rather than a hard | ||
{{YEAR/demo|1999}} | {{YEAR/demo|1999}} | ||
{{YEAR/demo|1999-12-12}} | {{YEAR/demo|1999-12-12}} | ||
| Line 20: | Line 19: | ||
Reports "Error" if given bad input: | Reports "Error" if given bad input: | ||
{{YEAR/demo|1-14-1990}}<br /> | {{YEAR/demo|1-14-1990}}<br />Reason for the error: there are not 14 months. | ||
{{YEAR/demo|61 January 1999}}<br /> | {{YEAR/demo|61 January 1999}}<br />Reason for the error: no month has 61 days. | ||
{{YEAR/demo|1 MyMonth 1999}}<br /> | {{YEAR/demo|1 MyMonth 1999}}<br />Reason for the error: there is no such month name. | ||
{{YEAR/demo|some text which is not a date}}<br /> | {{YEAR/demo|some text which is not a date}}<br />Reason for the error: no date information to parse. | ||
{{YEAR/demo|on approximately 1999-12-12}}<br /> | {{YEAR/demo|on approximately 1999-12-12}}<br />Reason for the error: includes extraneous content. | ||
If used with a year range, it returns only the first match: | If used with a year range, it returns only the first match: | ||
| Line 37: | Line 36: | ||
It can be cleanly substituted for this purpose. If fed invalid data when substituted, it produces a larger, red error. | It can be cleanly substituted for this purpose. If fed invalid data when substituted, it produces a larger, red error. | ||
<includeonly>{{Sandbox other|| | <includeonly>{{Sandbox other|| | ||
Latest revision as of 17:43, 9 April 2025
| This page uses Creative Commons Licensed content from Wikipedia (view authors). |
| This is a documentation subpage for Template:YEAR It may contain usage information, categories and other content that is not part of the original template page. |
Usage
{{YEAR|string formatted as a valid date}}
Specify optional parameter to get soft error rather than a hard Template:YEAR/demo Template:YEAR/demo Template:YEAR/demo Template:YEAR/demo Template:YEAR/demo Template:YEAR/demo Template:YEAR/demo Template:YEAR/demo
Reports "Error" if given bad input:
Template:YEAR/demo
Reason for the error: there are not 14 months.
Template:YEAR/demo
Reason for the error: no month has 61 days.
Template:YEAR/demo
Reason for the error: there is no such month name.
Template:YEAR/demo
Reason for the error: no date information to parse.
Template:YEAR/demo
Reason for the error: includes extraneous content.
If used with a year range, it returns only the first match:
This presently only works when the year range is specified with a hyphen; if correctly given with an en dash, it reports an error (this will probably not be fixed, because handling ranges is not the template's function; that it kinda-sorta works on something like 1999-2001 with a hyphen is basically just an accident):
If used without input, it simply outputs the current year:
It can be cleanly substituted for this purpose. If fed invalid data when substituted, it produces a larger, red error.