Template:Date formatter: Difference between revisions

From stencil.wiki
(Created page with "<includeonly>{{#if:{{#ifeq:{{#time:Ymd|{{{start_date|}}}}}|{{#time:Ymd|{{{end_date|}}}}}|1|}}| {{#time:F j, Y|{{{start_date|}}}}} <!-- If the dates are the same --> | <!-- If the dates are different --> <span>{{#time:F j, Y|{{{start_date|}}}}} - {{#time:F j, Y|{{{end_date|}}}}}</span> }}</includeonly><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...")
 
No edit summary
Line 1: Line 1:
<includeonly>{{#if:{{#ifeq:{{#time:Ymd|{{{start_date|}}}}}|{{#time:Ymd|{{{end_date|}}}}}|1|}}|
<includeonly>
  {{#time:F j, Y|{{{start_date|}}}}} <!-- If the dates are the same -->
{{#invoke:DateComparison|compareDates|start_date={{{start_date|}}}|end_date={{{end_date|}}}}}
| <!-- If the dates are different -->
</includeonly>
  <span>{{#time:F j, Y|{{{start_date|}}}}} - {{#time:F j, Y|{{{end_date|}}}}}</span>
}}</includeonly><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".



Revision as of 00:53, 8 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={{{start_date|}}} | end_date = {{{end_date|}}}}}

Examples

The following examples use hard-coded dates, for examples sake.

{{Date comparison | start_date = 2024/12/07 | end_date = 2024/12/07}}

Template:Date comparison

{{Date comparison | start_date = 2024/12/07 | end_date = 2024/12/09}}

Template:Date comparison