Jump to content

Module:FindYDCportal/doc

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by BrownHairedGirl (talk | contribs) at 23:12, 22 November 2018 (See also: typo). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

A helper module to find the most specific chronology portal which actually exists for a given year or decade. Used to simplify linking to a chronology portal.

Takes one parameter, which must be either a year (e.g. "1879", "1123") or a decade (e.g. "1940s", "730s").

If the parameter is missing, empty, or does not fit the required format, an empty string is returned.

Output

If a portal is found, returns its name without the namespace prefix, e.g.

If no portal is found, it returns an empty string.

Usage

{{#invoke: FindYDCportal | findydcportal |YYYY}}

Examples

Years
  • {{#invoke: FindYDCportal | findydcportal |2018}} → 2010s
  • {{#invoke: FindYDCportal | findydcportal |1935}}
  • {{#invoke: FindYDCportal | findydcportal |1857}}
  • {{#invoke: FindYDCportal | findydcportal |736}}
  • {{#invoke: FindYDCportal | findydcportal |1800}}
Decades
  • {{#invoke: FindYDCportal | findydcportal |2000s}} → 2000s
  • {{#invoke: FindYDCportal | findydcportal |1940s}}
  • {{#invoke: FindYDCportal | findydcportal |560s}}
Missing parameter
  • {{#invoke: FindYDCportal | findydcportal}}
Empty parameter
  • {{#invoke: FindYDCportal | findydcportal | }}
Invalid parameter
  • {{#invoke: FindYDCportal | findydcportal | 1927-related}}
  • {{#invoke: FindYDCportal | findydcportal | Swedish chef}}

Logic

If the parameter is a year:

  1. If the year portal exists, return its name.
    Otherwise try the decade.
  2. If the decade portal exists, return its name.
    Otherwise try the century
  3. If the century portal exists, return its name.
    Otherwise return an empty string

If the parameter is a decade:

  1. If the decade portal exists, return its name.
    Otherwise try the century
  2. If the century portal exists, return its name.
    Otherwise return an empty string

See also