Swift

Simple ordinal date queries in Swift

That happy moment when the API you need already exists

Ronald Martin

4 minute read

I had a very specific question a while ago: When is the next 5th Sunday of the month? That is, what is the next date which is not only a Sunday, but also the 5th occurrance of Sunday in its enclosing month? This only occurs a handful of times in any given year (in the Gregorian calendar): an average of 30 days per month means 30 days/month / 7 days/week = ~4.