Difference between revisions of "Template:NthDayOfMonth"

From Hackerspace ACKspace
Jump to: navigation, search
(THEREIFIXEDIT (I hope))
m (ok minor final update, really)
 
Line 11: Line 11:
 
</noinclude>
 
</noinclude>
 
{{#ifexpr: {{{nth|1}}} > 0
 
{{#ifexpr: {{{nth|1}}} > 0
| above 0:{{#expr: {{#ifexpr: {{{day|6}}} >= {{#time: w|1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} | 1 | 8 }} + {{{day|6}}} - {{#time: w|1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} + ({{{nth|1}}} - 1 ) * 7 }}-{{{month|{{CURRENTMONTH}}}}}
+
| {{#expr: {{#ifexpr: {{{day|6}}} >= {{#time: w|1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} | 1 | 8 }} + {{{day|6}}} - {{#time: w|1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} + ({{{nth|1}}} - 1 ) * 7 }}
 
+
| {{#expr: {{#ifexpr: {{{day|6}}} > {{#time: w|{{#time: t | 1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }}-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} | -7 | 0 }} + {{#time: t | 1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} + {{{day|6}}} - {{#time: w|{{#time: t | 1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }}-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} + ({{{nth|1}}}) * 7 }}
| 0 and below:{{#expr: {{#ifexpr: {{{day|6}}} > {{#time: w|{{#time: t | 1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }}-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} | -7 | 0 }} + {{#time: t | 1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} + {{{day|6}}} - {{#time: w|{{#time: t | 1-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }}-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}} }} + ({{{nth|1}}}) * 7 }}-{{{month|{{CURRENTMONTH}}}}}
+
}}-{{{month|{{CURRENTMONTH}}}}}-{{{year|{{CURRENTYEAR}}}}}
}}
 

Latest revision as of 16:28, 1 December 2017

See if we can create a template where we can show the n-th day of the month, like the first sunday or second to last saturday (months can have 4 or 5 of the same weekdays in it)

Params:

  • 1 defaults to 'first'. positive numbers mean first (1), second (2).. Other numbers mean last (0), second to last (-1)
  • 6 defaults to 'Saturday' 0=Sunday, 1=Monday...
  • 11 defaults to month of upcoming occurrence (this or next month)
  • 2024 defaults to year of upcoming occurrence (this or next year)

The use of {{NthDayOfMonth}} would result in:

2-11-2024