ISO8601DateFormatter does not allow for decimal fractions of smallest time component.

Originator:oliver.foggin
Number:rdar://34430629 Date Originated:14/09/17
Status:Open Resolved:
Product:iOS SDK - Foundation Product Version:iOS 10+
Classification:Suggestion Reproducible:Always
 
As per this website... https://www.cl.cam.ac.uk/~mgk25/iso-time.html ... and Wiki and various other references for the ISO8601 date format...

"It is also possible to add fractions of a second after a decimal dot or comma, for instance the time 5.8 ms before midnight can be written as 23:59:59.9942 or 235959.9942"

The actual standard is that a fraction can be added to the smallest of the time component included in the format. So three and a half minutes past 1 pm can be indicated with a time format of `13:03.5` (using a comma or full stop for the decimal point).

The ISO8601DateFormatter added in iOS10 does not include an option to customise the decimal part of the format and so for many commonly used web formats... `yyyyMMddTHH:mm:ss.SSSSZ` cannot be converted into a Date using the ISO8601DateFormatter and instead returns `nil`.

In order to conform to the ISO8601 standard this should be added.

The standard says that the number of decimals is not set as part of the standard and should be agreed between the writers and consumers of the API.

So, not only should the fraction of the smallest time component be part of the `ISO8601DateFormatter.Options` (with a name something like `withFractionalTime`) but it should also allow for the configuration of the number of decimal places required.

Thanks

Comments

I reported this as 27689420 and it was closed as a dupe of 24532185.

Very stupid this still isn't fixed.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!