Difference between revisions of "Template:Days after date"

From mtgpq wiki
Jump to: navigation, search
 
Line 48: Line 48:
 
{{Days after date|2400|February|28|5}}
 
{{Days after date|2400|February|28|5}}
  
</noinclude><includeonly><!-- The calculation is ((day of month + day of week - 2) mod (days in month)) + 1
+
</noinclude><includeonly>{{#expr:(({{{3}}} + {{{4}}} - 2) mod {{Days in month|{{{2}}}|{{{1}}}}}) + 1}}</includeonly>
-->{{#expr:(({{{3}}} + {{{4}}} - 2) mod (<!--
 
-->{{#switch:{{{2}}}
 
|April |June |September |November=30
 
|February=({{#ifexpr:((({{{1}}} mod 4) > 0) or ((({{{1}}} mod 100) = 0) and (({{{1}}} mod 400) > 0)))|28|29}})
 
|31}})) + 1}}</includeonly>
 

Latest revision as of 02:40, 4 March 2019

Usage

Returns the numerical day of the month relative to a given date.

The first three parameters are the year, month name, and day number of a date which is taken as the start of a week.

The fourth parameter is a number from 1 to 7 representing the day of the week.

Example

The following shorthand:

{{Days after date|2019|January|28|5}}
{{Days after date|2019|February|28|5}}
{{Days after date|2019|March|28|5}}
{{Days after date|2019|April|28|5}}
{{Days after date|2019|May|28|5}}
{{Days after date|2019|June|28|5}}
{{Days after date|2019|July|28|5}}
{{Days after date|2019|August|28|5}}
{{Days after date|2019|September|28|5}}
{{Days after date|2019|October|28|5}}
{{Days after date|2019|November|28|5}}
{{Days after date|2019|December|28|5}}

{{Days after date|2020|February|28|5}}
{{Days after date|2100|February|28|5}}
{{Days after date|2400|February|28|5}}

Produces:

1 4 1 2 1 2 1 1 2 1 2 1

3 4 3