Especially with modern Swift syntax, complex questions like "what's the current day of the year" end up having simple, almost poetic answers like "calendar.ordinality(of: .day, in: .year, for: date)". And you can trust that they are correct for every calendar and every locale. Usually. [2]
[1] https://itunes.apple.com/us/app/better-day-a-complication/id...
[2] https://www.joeycastillo.com/notes/2016/09/18/of-crescent-mo...