Template:ISOyear


Dialog-warning-orange.svg Note: This template is used on a lot of pages. In order not to put too much load on the servers, edits should be kept to a bare minimum. Please discuss proposed changes on the talk page first.
  • Editing a template causes all pages that use the template to be re-rendered. If the template is used often, this can put a lot of load on the servers since it fills up the job queue.
  • Keep in mind that templates that are used on file description pages also show up on other wikis.
  • This page has been protected from editing to prevent vandalism. Only administrators can edit it. Get their attention by placing {{edit protected}} at the talk page.
Documentation icon Documentationviewedithistorypurge

This documentation is transcluded from Template:ISOyear/doc.

Extracts year from calendar dates in ISO 8601 extended format (YYYY-MM-DD, e.g. "2017-03-28"). This template is very similar to {{#time: Y}} parser function , but accepts a year as input, even in cases where #time would interpret that as a time. In the case of wrong input template does not return anything.

Usage

{{ISOyear |1= }}

Template parameters

Parameter Description Default Status
1 date in ISO 8601 format. Supported formats: YYYY-MM-DD, YYYY-MM, YYYY. Other formats not officially supported but returning correct results include: single digit months and days and years without months or days can have any number of digits. Supported dates are any proleptic Gregorian calendar or Gregorian calendar dates between 1 January 0001 AD and 31 December 9999 AD. empty required

Additional information

The template is intended to be used in the following namespaces: all namespaces

The template is intended to be used by the following user groups: all users

Relies on:
Module:Date

See also

{{ISOdate}}

Localization

This template is not intended to be localized.

Testing

More tests can be found at Template:ISOyear/testcases.

YYYY-MM-DD tests:

  1. {{ISOyear|2009-09-09}} gives "2009"
  2. {{ISOyear|2009-09-9}} gives "2009"
  3. {{ISOyear|2009-9-09}} gives "2009"
  4. {{ISOyear|0909-09-09}} gives "0909"
  5. {{ISOyear|909-09-09}} gives "0909"
  6. {{ISOyear|0099-09-09}} gives "0099"
  7. {{ISOyear|099-09-09}} gives "0099"
  8. {{ISOyear|99-09-09}} gives "0099"
  9. {{ISOyear|+2009-09-09}} gives "2009"
  10. {{ISOyear|-2009-09-09}} gives "-2009"
  11. {{ISOyear|2009-13-09}} gives "2009"
  12. {{ISOyear|2009-09-35}} gives "2009"
  13. {{ISOyear|2009+09+09}} gives ""
  14. {{ISOyear|2009/09/09}} gives ""
  15. {{ISOyear|2009 09 09}} gives ""

YYYY-MM tests:

  1. {{ISOyear|2009-09}} gives "2009"
  2. {{ISOyear|2009-9}} gives "2009"
  3. {{ISOyear|2009-13}} gives "2009"
  4. {{ISOyear|0909-09}} gives "0909"
  5. {{ISOyear|909-09}} gives "0909"
  6. {{ISOyear|0100-09}} gives "0100"
  7. {{ISOyear|0099-09}} gives "0099"
  8. {{ISOyear|099-09}} gives "0099"
  9. {{ISOyear|99-09}} gives "0099"
  10. {{ISOyear|+2009-09}} gives "2009"
  11. {{ISOyear|-2009-09}} gives "-2009"
  12. {{ISOyear|2009/09}} gives ""
  13. {{ISOyear|2009+09}} gives ""

YYYY tests:

  1. {{ISOyear|2009}} gives "2009"
  2. {{ISOyear|+2009}} gives "2009"
  3. {{ISOyear|-2009}} gives "-2009"
  4. {{ISOyear|0999}} gives "0999"
  5. {{ISOyear|999}} gives "0999"
  6. {{ISOyear|0099}} gives "0099"
  7. {{ISOyear|099}} gives "0099"
  8. {{ISOyear|99}} gives "0099"
  9. {{ISOyear|9}} gives "0009"
  10. {{ISOyear|0}} gives "0000"

0ther:

  1. {{ISOyear}} gives ""
  2. {{ISOyear|24 December 1798}} gives ""
  3. {{ISOyear|hello}} gives ""
https://commons.m.wikimedia.org/wiki/Template:ISOyear
commons.m.wikimedia.org
crawl=CC-MAIN-2017-13
24496
application/http; msgtype=response
sha1:5H5OZYUKBQZZFNYREVWLFWTUEAZS2EJW
<urn:uuid:e40f0cfa-b2f7-4de0-994d-0a7294e1be91>
2017-03-28T19:52:50Z
208.80.154.224
sha1:EFHJOHT45LHUK2TYPO4ZQVXKVXUCDQY6
<urn:uuid:754a9e5d-faf0-44c3-8848-03158cb0699d>
https://commons.m.wikimedia.org/wiki/Template:ISOyear
length
response
<urn:uuid:47608f5c-73e3-4e13-8dc6-1576ad379068>
robots: classic
hostname: ip-10-233-31-227.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2017-13
operator: CommonCrawl Admin
description: Wide crawl of the web for March 2017
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf