Determining the Date of the [nth] [Day] in [Month]
I'm looking for an algorithm to calculate the date of the last [day] in a given [month]. For example, the last Sunday in March.
You may have guessed that this relates to Daylight Saving/British Summer Time. We want something user-entered but algorithmically calculated (so you enter the rule and thereafter don't have to change the dates every year), such that Americans can set it up our way, and Europeans can set it up their way. That type of thing.
I've tried searching the web, and again wandered through some fine documents that reminded me of exactly why it has that I disliked working with date and time. I've been trying search terms such as algorithm calculate "last Sunday of March", but coming up a little empty. Maybe I've just chosen bad search terms.
But if anyone knows a resource, I thank you for pointing me the right way.