How to get components from a date in Swift

I had the hardest time figuring out how to create NSDateComponents from a date in Swift. How do you tell NSCalendar which units you want? You can’t do what you’d do in Objective-C…

I eventually stumbled across a solution. Here’s how to get components from a date in Swift, specifying the NSCalendarUnit flags: