Given a standard piece of scheduling information, such as "the second Tuesday in June 2009" or "the last Friday in July 2009", what's the simplest and most efficient formula to translate that into a date?
Inputs:
w
= Week of month, enumeration (1st, 2nd, 3rd, 4th or Last)d
= Day of week, enum Sun through Satm
= Month, integery
= Year, integer
EDIT (again) - It doesn't matter what day the week begins on; I want to get the wth instance of d in the given month. Thus the 2nd Sunday in June 2009 is 14 June, even though that technically falls in the 3rd week of June; similarly the 1st Sunday in June is 7 June, not null/exception.