Oracle has a very useful function for finding the date of the next weekday. This function is called NEXT_DAY
. It takes a start date, say 15-OCT-2009
, and the weekday we're expecting, say TUESDAY
. The result of NEXT_DAY('15-OCT-2009', 'TUESDAY')
is 20-OCT-2009
because that's the next Tuesday after the 15th of October 2009.
Does Python have a function, be it Built-in or via the datetime library, that does this same thing?
I need it to deterministically return true/false for the question "if this day was in November, is it Thanksgiving?" without referencing any kind of lookup table for any year.
It's used by looking at the day number, the 15th part from above, and finding the number of days until the next Thursday in October then adding 21 to that. An alternative method of answering the question "is the day Thanksgiving?", deterministically, at runtime, without any lookup tables, restricted to plain Python or the datetime library would work for my situation but would not work to answer the question in the title.