If you appreciate the work done within the wiki, please consider supporting The Cutting Room Floor on Patreon. Thanks for all your support!

User:結衣/Templates/ReleaseDate

From The Cutting Room Floor
Jump to navigation Jump to search

Provide a valid release date

About

This is a sane version of Template:Date that uses the #time ParserFunction provided graciously by Extension:ParserFunctions. This template meets feature parity with Template:Date and boasts several advantages, like

  • backwards compatibility with Template:Date
    • disables formatting to user preference because this version of MediaWiki has a jank {{ #dateformat: }} that was fixed only in version 1.38.2 and up)
    • categorizes page under [Category:Pages using old-style dates]
  • input validation and warnings
  • input canonicalization
  • arbitrary categorization guards
    • junk like {{date|stupid}} producing Category:Games released in stupid even in the main namespace
  • support for inputs in datetime formats accepted by the PHP strtotime() function
  • output formatted according to user preference (default to datetime format F j, Y for unregistered users)

Synopsis

Usage

{{ User:結衣/Templates/ReleaseDate | 1 [ | 2 [ | 3 ] ] [ | ref ] [ | nocat ] [ | nofmt ] }} 1 : string - a datetime string in a format accepted by the PHP `strtotime()` function (if parameters 2 or 3 specified) a numeral year without zero-padding 2 : optional string - a full month name in English 3 : optional string - a numeral day without zero-padding ref : string - a reference for the supplied date (ignored if invalid date supplied) nocat : string - flag for explicitly disabling categorization under [[Category:Games_released_in_<year>]] (ignored if invalid date supplied) nofmt : string - flag for overriding date formatting to user preference (because #dateformat output is incompatible with #time, this is useful for template interoperability)

Notes

Because valid inputs to strtotime() include relative and compound dates, one can abuse the template by inserting a randomized-on-view relative date that will continuously link to non-existent years.

Examples

I promise these will help eventually.

{{User:結衣/Templates/ReleaseDate}} -> Provide a release date {{User:結衣/Templates/ReleaseDate|2018-04-09}} -> April 9, 2018 {{User:結衣/Templates/ReleaseDate|April 09, 2018}} -> April 9, 2018 {{User:結衣/Templates/ReleaseDate|09 April 2018}} -> April 9, 2018 {{User:結衣/Templates/ReleaseDate|04/09/2018}} -> April 9, 2018 {{User:結衣/Templates/ReleaseDate|09-04-2018}} -> April 9, 2018 {{User:結衣/Templates/ReleaseDate|+1 day}} -> January 4, 2025 {{User:結衣/Templates/ReleaseDate|2018}} -> 2018 {{User:結衣/Templates/ReleaseDate|2018|April}} -> April 2018 {{User:結衣/Templates/ReleaseDate|2018|April|9}} -> April 9, 2018 {{User:結衣/Templates/ReleaseDate|2018|9}} -> Provide a valid release date {{User:結衣/Templates/ReleaseDate|2018|04|09}} -> Provide a valid release date {{User:結衣/Templates/ReleaseDate|April|04|2018}} -> Provide a valid release date {{User:結衣/Templates/ReleaseDate|2018-04-09|ref=<ref>The release date of <cite>Lobotomy Corporation</cite></ref>}} -> April 9, 2018 {{User:結衣/Templates/ReleaseDate|2018-04-09|nofmt=1}} -> 2018-04-09T00:00:00+00:00 {{User:結衣/Templates/ReleaseDate|I don't know what a date is.}} -> Provide a valid release date

References