Difference between revisions of "Template:NthDayOfMonth"

From Hackerspace ACKspace
Jump to: navigation, search
(WIP: template to return a date given the n-th weekday of the month)
 
m (nailed it (the reverse day of month))
Line 22: Line 22:
 
*: the second wednesday of the month is: {{#expr: {{#ifexpr: 3 >= {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 8 }} + 3 - {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (2 - 1 ) * 7 }}-{{CURRENTMONTH}}
 
*: the second wednesday of the month is: {{#expr: {{#ifexpr: 3 >= {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 8 }} + 3 - {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (2 - 1 ) * 7 }}-{{CURRENTMONTH}}
 
*: the first Tuesay of the month is: {{#expr: {{#ifexpr: 2 >= {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 8 }} + 2 - {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (1 - 1 ) * 7 }}-{{CURRENTMONTH}}
 
*: the first Tuesay of the month is: {{#expr: {{#ifexpr: 2 >= {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 8 }} + 2 - {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (1 - 1 ) * 7 }}-{{CURRENTMONTH}}
*: the second Tuesay of the month is: {{#expr: {{#ifexpr: 2 >= {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 8 }} + 2 - {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (2 - 1 ) * 7 }}-{{CURRENTMONTH}}
+
*: the second Tuesday of the month is: {{#expr: {{#ifexpr: 2 >= {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 8 }} + 2 - {{#time: w|1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (2 - 1 ) * 7 }}-{{CURRENTMONTH}}
  
 
* TODO:
 
* TODO:
*: the last saturday of the month is: {{#expr: {{#ifexpr: 6 >= {{#time: w|30-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 80 }} + 6 - {{#time: w|30-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (0 - 1 ) * 7 }}-{{CURRENTMONTH}}
+
*: the last saturday of the month is: {{#expr: {{#ifexpr: 6 > {{#time: w|{{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }}-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | -7 | 0 }} + {{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + 6 - {{#time: w|{{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }}-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + 0 * 7 }}-{{CURRENTMONTH}}
*: the last wednesday of the month is: {{#expr: {{#ifexpr: 3 >= {{#time: w|30-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 80 }} + 3 - {{#time: w|30-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (0 - 1 ) * 7 }}-{{CURRENTMONTH}}
+
*: the last wednesday of the month is: {{#expr: {{#ifexpr: 3 > {{#time: w|{{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }}-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | -7 | 0 }} + {{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + 3 - {{#time: w|{{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }}-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + 0 * 7 }}-{{CURRENTMONTH}}
*: the last Tuesay of the month is: {{#expr: {{#ifexpr: 2 >= {{#time: w|30-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | 1 | 80 }} + 2 - {{#time: w|30-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (0 - 1 ) * 7 }}-{{CURRENTMONTH}}
+
*: the last Tuesday of the month is: {{#expr: {{#ifexpr: 2 > {{#time: w|{{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }}-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | -7 | 0 }} + {{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + 2 - {{#time: w|{{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }}-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + 0 * 7 }}-{{CURRENTMONTH}}
 
+
*: the second to last saturday of the month is: {{#expr: {{#ifexpr: 6 > {{#time: w|{{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }}-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} | -7 | 0 }} + {{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + 6 - {{#time: w|{{#time: t | 1-{{CURRENTMONTH}}-{{CURRENTYEAR}} }}-{{CURRENTMONTH}}-{{CURRENTYEAR}} }} + (-1) * 7 }}-{{CURRENTMONTH}}
 
 
{{#time: t | 1-11-2017 }}
 
 
 
 
 
 
 
{{#time: Y/m/d | 0-12-2017 }}
 
{{#time: Y/m/d | 32-12-2017 }}
 
 
 
 
 
{{#time: Y/m/d | 0-13-2017 }}
 
 
 
 
 
 
 
 
 
  
  

Revision as of 16:12, 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...
  • jan defaults to month of upcoming occurrence (this or next month)
  • 2018 defaults to year of upcoming occurrence (this or next year)


  • determine weekday for the beginning of the month, requested, end of the month
    5, 6, 6
  • nth week in the month
    0
  • requested weekday > month-day ? rd - md : 7 + rd - md
  • working:
    the (first) (saturday) of the month is: 2-11
    the first saturday of the month is: 2-11
    the second saturday of the month is: 9-11
    the fourth saturday of the month is: 23-11
    the fifth saturday of the month is: 30-11
    the first wednesday of the month is: 6-11
    the second wednesday of the month is: 13-11
    the first Tuesay of the month is: 5-11
    the second Tuesday of the month is: 12-11
  • TODO:
    the last saturday of the month is: 30-11
    the last wednesday of the month is: 27-11
    the last Tuesday of the month is: 26-11
    the second to last saturday of the month is: 23-11