> I'm now trying to find why, along with changing from NSCalendar to Calendar, 
> the .components are optional. I can't find any mention of it, and I'm not 
> sure in what situation minutes or hours could be nil and how I should guard 
> against it.

In Objective-C, these properties can be `NSUndefinedDateComponent`. In Swift, 
that's represented as `nil` instead.

Essentially, this happens when you don't request a particular date 
component—for instance, when you say `gregorian.components([.year, .month, 
.day], fromDate: date)`, `hours` and `minutes` will be `nil`. In Objective-C, 
they would have been `NSUndefinedDateComponent`.

-- 
Brent Royal-Gordon
Architechies

_______________________________________________
swift-users mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to