Template:NthDayOfMonth

From Hackerspace ACKspace
Revision as of 17:12, 1 December 2017 by Xopr (talk | contribs) (nailed it (the reverse day of month))
Jump to: navigation, search

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
    1, 6, 2
  • nth week in the month
    0
  • requested weekday > month-day ? rd - md : 7 + rd - md
  • working:
    the (first) (saturday) of the month is: 6-04
    the first saturday of the month is: 6-04
    the second saturday of the month is: 13-04
    the fourth saturday of the month is: 27-04
    the fifth saturday of the month is: 34-04
    the first wednesday of the month is: 3-04
    the second wednesday of the month is: 10-04
    the first Tuesay of the month is: 2-04
    the second Tuesday of the month is: 9-04
  • TODO:
    the last saturday of the month is: 27-04
    the last wednesday of the month is: 24-04
    the last Tuesday of the month is: 30-04
    the second to last saturday of the month is: 20-04