User:Andrew Nikitin/weekdaynth

From J Wiki
Jump to navigation Jump to search
require 'dates'

NB.*weekdaynth v returns the date triple of the nth weekday of the month
NB. x=(year,month) -- defults to current year an month
NB. y=weekday,number
weekdaynth=:3 : 0
(2 {. 6!:0 '') weekdaynth y
:
'w n'=.2 {.!.1 y
f=.weekday x,1
x, 1+(7*_1+n)+7|w-f
)