Template:NthDayOfMonth

From Hackerspace ACKspace
Revision as of 18:51, 28 November 2017 by Xopr (talk | contribs) (WIP: template to return a date given the n-th weekday of the month)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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
    3, 6, 5
  • nth week in the month
    0
  • requested weekday > month-day ? rd - md : 7 + rd - md
  • working:
    the (first) (saturday) of the month is: 4-05
    the first saturday of the month is: 4-05
    the second saturday of the month is: 11-05
    the fourth saturday of the month is: 25-05
    the fifth saturday of the month is: 32-05
    the first wednesday of the month is: 1-05
    the second wednesday of the month is: 8-05
    the first Tuesay of the month is: 7-05
    the second Tuesay of the month is: 14-05
  • TODO:
    the last saturday of the month is: -4-05
    the last wednesday of the month is: 72-05
    the last Tuesay of the month is: 71-05


30


2017/11/30 Error: Invalid time.


Error: Invalid time.