NSDateComponentsFormatter.allowsFractionalUnits does not work

Number:rdar://22660145 Date Originated:11-Sep-2015 03:13 PM
Status:Open Resolved:
Product:iOS SDK Product Version:
Classification:Other Bug Reproducible:Always
I can't get the NSDateComponentsFormatter to give me a decimal value. I have tried in Swift and Objective-C and turning on allowsFractionalUnits doesn't seem to do anything.

Steps to Reproduce:
Swift code:
let formatter = NSDateComponentsFormatter()
formatter.unitsStyle = .Abbreviated
formatter.allowedUnits = .Hour
formatter.allowsFractionalUnits = true

let onePointFiveHoursInSeconds = NSTimeInterval(1.5 * 60.0 * 60.0)
//"1h" instead of expected "1.5h"

Expected Results:
"1.5h" printed

Actual Results:
"1h" printed


Update from Apple in 2019

"Unfortunately, the fix here is nontrivial, and other tasks have taken precedence. This is something we'd still like to resolve, and we’ll be tagging this for a more prioritized fix."

Any news on this bug?

By Sliwinski.Lukas at June 13, 2016, 10:04 a.m. (reply...)

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!