Template:Main page date/doc

From Yugipedia
Jump to: navigation, search

{{Main page date}} formats dates used in entries in {{News}}, which is displayed on the main page.

Usage

This template accepts one unnamed parameter, the date to be formatted, which may be provided in either Month D, Year format (e.g. June 6, 2024; F j, Y in PHP's strtotime() format) or D Month Year format (e.g. 6 June 2024; j F Y in PHP's strtotime() format).

Current usage of this template is to format the output of Semantic MediaWiki queries in {{News}}, e.g. {{ #ask: [[Page type::Set page]] [[English release date::>{{ #time: Y-m-d | now - 15 days }}]] | ?English release date | link=none | format=template | template=Set news list | default = No known releases. }}.

This template correctly handles the following date formats:

  • Month Day, Year (June 6, 2024); Month Day Year (June 6 2024); Day Month Year (6 June 2024); Day Month, Year (6 June, 2024): returns Month Day (June 6) for dates in the current year (2024), or Month Day, Year (June 6, 2024) for dates in other years.
  • Month Year (June 2024); Month, Year (June, 2024); Year Month (2024 June); Year, Month (2024, June): returns Month (June) for dates in the current year (2024), or Month Year (June 2024) for dates in other years.
  • Year (2024): always returns Year (2024).

Any other input is considered invalid and returns blank (even if it would otherwise be a valid date; e.g. ISO 8601-formatted dates are not supported).

Code Result Notes
{{Main page date|September 16, 1996}} September 16, 1996 Full date, not current year
{{Main page date|September 1996}} September 1996 Month Year, not current year
{{Main page date|September, 1996}} September 1996 Month Year, separated by comma, not current year
{{Main page date|1996}} 1996 Year, not current year
{{Main page date|September 16, 2024}} September 16 Full date, current year
{{Main page date|September 2024}} September Month Year, current year
{{Main page date|September, 2024}} September Month Year, separated by comma, current year
{{Main page date|2024}} 2024 Year, current year
{{Main page date|1996 September}} September 1996 Year Month input format works
{{Main page date|16 September 1996}} September 16, 1996 Day Month Year
{{Main page date|September 16}} Dates without a year are not supported
{{Main page date|16 September}} regardless of whether they're Month Day or Day month format
{{Main page date|1996-09-16}} ISO 8601 dates aren't supported either
{{Main page date|16, 1996}} Dates with a day but no month also aren't supported

See also