Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:YEAR/doc: Difference between revisions

Template page
Created page with "{{wikipedia|page name}} {{Documentation subpage}} <!-- 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}} {{High-use}} == Usage == {{Tlx|YEAR|{{var|string formatted as a valid date}}}} Specify optional parameter {{param|2}} to get soft error rather than a hard {{t|error}} {{YEAR/demo|1999}} {{YEAR/demo|1999-12-12}} {{YEAR..."
 
No edit summary
Line 36: Line 36:
*{{YEAR/demo|}}
*{{YEAR/demo|}}


It can be cleanly [[WP:SUBST|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.


== See also ==
== See also ==
Line 42: Line 42:
* {{tlx|date}} – outputs the current date in various parameter-controlled formats
* {{tlx|date}} – outputs the current date in various parameter-controlled formats
* {{tlx|DATE}} – a subst-only convenience template used inside cleanup/dispute templates; {{tlsx|DATE}} produces: <samp>date={{CURRENTMONTHNAME}} {{CURRENTYEAR}}</samp>
* {{tlx|DATE}} – a subst-only convenience template used inside cleanup/dispute templates; {{tlsx|DATE}} produces: <samp>date={{CURRENTMONTHNAME}} {{CURRENTYEAR}}</samp>
* [[:Category:Time, date and calendar templates]] – numerous date computing, formatting, annotating, and navigation templates
* :Category:Time, date and calendar templates – numerous date computing, formatting, annotating, and navigation templates


<includeonly>{{Sandbox other||
<includeonly>{{Sandbox other||

Revision as of 11:19, 8 April 2025

This page uses Creative Commons Licensed content from Wikipedia (view authors).

Template:High-use

Usage

{{YEAR|string formatted as a valid date}}

Specify optional parameter Template:Param to get soft error rather than a hard {{error}} 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
Template:In5Reason for the error: there are not 14 months. Template:YEAR/demo
Template:In5Reason for the error: no month has 61 days. Template:YEAR/demo
Template:In5Reason for the error: there is no such month name. Template:YEAR/demo
Template:In5Reason for the error: no date information to parse. Template:YEAR/demo
Template:In5Reason 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.

See also

  • {{date}} – outputs the current date in various parameter-controlled formats
  • {{DATE}} – a subst-only convenience template used inside cleanup/dispute templates; {{subst:DATE}} produces: date=August 2026
  • :Category:Time, date and calendar templates – numerous date computing, formatting, annotating, and navigation templates