Template:Date formatter: Difference between revisions
IssuePress (talk | contribs) No edit summary |
IssuePress (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
<includeonly>{{#if:{{{ | <includeonly> | ||
{{#ifeq:{{{ | {{#if:{{{2|}}}| | ||
{{#time:F j, Y|{{{ | {{#ifeq:{{{1}}}|{{{2}}}| | ||
{{#time:F j, Y|{{{1}}}}}| | |||
}} | {{#time:F j, Y|{{{1}}}}} – {{#time:F j, Y|{{{2}}}}} | ||
}}| | |||
}}</includeonly> | Invalid input | ||
}} | |||
</includeonly> | |||
<noinclude> | <noinclude> | ||
This formatting template compares two dates (start_date and end_date). If the dates are the same, it displays the single date; otherwise, it displays a range in the format "December 7, 2024 - December 9, 2024". | This formatting template compares two dates (start_date and end_date). If the dates are the same, it displays the single date; otherwise, it displays a range in the format "December 7, 2024 - December 9, 2024". | ||
Line 12: | Line 14: | ||
It is meant to be used with variables, like <nowiki>{{{start_date}}}</nowiki>: | It is meant to be used with variables, like <nowiki>{{{start_date}}}</nowiki>: | ||
<pre> | <pre> | ||
{{Date comparison | | {{Date comparison |<start-date>|<end-date>}} | ||
</pre> | </pre> | ||
Line 18: | Line 20: | ||
The following examples use hard-coded dates, for examples sake. | The following examples use hard-coded dates, for examples sake. | ||
<pre> | <pre> | ||
{{Date comparison | | {{Date comparison|2024/12/07|2024/12/07}} | ||
</pre> | </pre> | ||
{{Date comparison | | {{Date comparison|2024/12/07|2024/12/07}} | ||
<pre> | <pre> | ||
{{Date comparison | | {{Date comparison |2024/12/07 |2024/12/09}} | ||
</pre> | </pre> | ||
{{Date comparison | | {{Date comparison |2024/12/07 |2024/12/09}} | ||
</noinclude> | </noinclude> |
Revision as of 23:55, 12 December 2024
This formatting template compares two dates (start_date and end_date). If the dates are the same, it displays the single date; otherwise, it displays a range in the format "December 7, 2024 - December 9, 2024".
Usage
It is meant to be used with variables, like {{{start_date}}}:
{{Date comparison |<start-date>|<end-date>}}
Examples
The following examples use hard-coded dates, for examples sake.
{{Date comparison|2024/12/07|2024/12/07}}
{{Date comparison |2024/12/07 |2024/12/09}}