ISO8601 icon indicating copy to clipboard operation
ISO8601 copied to clipboard

Can -ISO8601String ever be nil?

Open kengruven opened this issue 8 years ago • 0 comments

This library is great! One question: can NSDate -ISO8601String ever be nil?

It's marked __nullable, but I'm not sure I understand why. It calls -ISO8601StringWithTimeZone (also __nullable), which in turn calls +stringForDateComponents, which is __nullable. That method returns nil if !hasDate && !hasTime, which makes sense.

I understand why the string formatter for NSDateComponents has to check this, and therefore be nullable. But if it's being called on a converted NSDate, that's always going to have them, right?

I guess what I'm suggesting is either:

  • NSDate -ISO8601String (and its WithTimeZone variant) shouldn't be __nullable, or:
  • it should document in what case these can return nil (because unlike the parsers, or the NSDateComponents variants, it's not at all obvious)

Thanks!

kengruven avatar Sep 21 '17 00:09 kengruven