Difference between revisions of "Template:Check date"

From blackwiki
Jump to navigation Jump to search
imported>Pomte
(better examples)
imported>Fuhghettaboutit
m (Changed protection level of Template:Check date ([Edit=Allow only template editors and admins] (indefinite) [Move=Allow only template editors and admins] (indefinite)))
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{#if:{{{1|}}}|{{#ifeq:{{#time:F Y|{{{1}}}}}|Error: invalid time||{{#time:F Y|{{{1}}}}}}}}}<noinclude>
+
{{#if:{{{1|}}}|{{#iferror:{{#time:F Y|{{{1}}}}}||{{#time:F Y|{{{1}}}}}}}}}<noinclude>
This template is used to check whether the given parameter is a month. It is useful for templates such as {{tl|Articleissues}} that sort articles into [[:Category:Wikipedia cleanup categories|cleanup categories]] by month.
+
{{documentation}}
 
+
</noinclude>
If the parameter is a month/date/time formatted in the way recognized by [http://php.net/manual/en/function.strtotime.php PHP's strtotime()], this template returns the month in the format <code>Month Year</code>, where <code>Month</code> is written in full and <code>Year</code> is written in 4 digits.
 
 
 
If the parameter is not a month/date/time, the empty string is returned.
 
 
 
{| class="wikitable"
 
! Input
 
! Output
 
|-
 
| <nowiki>{{checkdate|April 2003}}</nowiki>
 
| {{checkdate|April 2003}}
 
|-
 
| <nowiki>{{checkdate|2003 April}}</nowiki>
 
| {{checkdate|2003 April}}
 
|-
 
| <nowiki>{{checkdate|Apr 2003}}</nowiki>
 
| {{checkdate|Apr 2003}}
 
|-
 
| <nowiki>{{checkdate|April 3 2003}}</nowiki>
 
| {{checkdate|April 3 2003}}
 
|-
 
| <nowiki>{{checkdate|April 03}}</nowiki>
 
| {{checkdate|April 03}} (thinks it is April 3 of the current year)
 
|-
 
| <nowiki>{{checkdate|y}}</nowiki>
 
| {{checkdate|y}}
 
|}</noinclude>
 

Latest revision as of 04:05, 2 November 2013

50px Template documentation[view] [edit] [history] [purge]

This template is used to check whether the given parameter is a month. It is useful for templates such as {{Multiple issues}} that sort articles into cleanup categories by month.

If the parameter is a month/date/time formatted in the way recognized by PHP's strtotime(), this template returns the month in the format Month Year, where Month is written in full and Year is written in 4 digits.

If the parameter is not a month/date/time, the empty string is returned.

Input Output
{{Check date|April 2003}} April 2003
{{Check date|2003 April}} April 2003
{{Check date|Apr 2003}} April 2003
{{Check date|April 3 2003}} April 2003
{{Check date|April 03}} April 2026 (thinks it is April 3 of the current year)
{{Check date|Garbage^&*text}}