MeasurementFormatter different behaviour for unitStyle

Originator:angrauel
Number:rdar://31807117 Date Originated:25-Apr-2017 10:32 AM
Status:Open Resolved:
Product:Foundation Product Version:iOS 10+
Classification:UI Reproducible:Always
 
Area:
Foundation

Summary:
The MeasurementFormatter doesn't format UnitTemperature the same way.

UnitStyle .long - shows always the same format 
UnitStyle .medium - shows different formats - "x °C", "x°C" or "x °C" "x °F"
UnitStyle .short - shows different formats - "x°", "x°C", "x°F"

Steps to Reproduce:
1. Create a sample application
2. Code
let measurement = Measurement<UnitTemperature>(value: 10, unit: .celsius)
let formatter = MeasurementFormatter()
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .none
        
formatter.numberFormatter = numberFormatter
formatter.unitStyle = .short
        
let degree = formatter.string(from: measurement)
print(degree)
3. Run the application with different Region, Language and TemperatureUnit settings.
4. See different results

Expected Results:
All unitStyles should be formatted identically otherwise it's not possible to define a specific user interface for the user.

Actual Results:
UnitStyle .long - shows always the same format 
UnitStyle .medium - shows different formats - "x °C", "x°C" or "x °C" "x °F"
UnitStyle .short - shows different formats - "x°", "x°C", "x°F"

Version:
iOS 10.3.1 (14E304)

Notes:
It would be awesome to have a variable to get the user setting for temperature unit. It's only possible to get the value with private api, then the formatter wouldn't be needed it would be possible to convert the UnitTemperature with Measurement convert(to:) method.

Configuration:
Any iOS 10.3 devices and possible earlier

Comments


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!