NSDateIntervalFormatter does not use 24hr time preference

Originator:jeff
Number:rdar://24639743 Date Originated:2/12/2016
Status:Open Resolved:
Product:iOS Product Version:9.2.1
Classification: Reproducible:Always
 
Summary:
If your device is set to use 24hr time (instead of AM/PM), the NSDateIntervalFormatter will still show times in AM/PM format. NSDateFormatter will correctly format using the 24hr time value.

Sample App:
https://github.com/jffmrk/NSDateIntervalFormatterBug

Steps to Reproduce:
1 - Device is in en_US locale
2 - Go to Settings -> Date & Time
3 - Turn on "24-Hour Time" switch
4 - Format a time interval using NSDateIntervalFormatter

Example code:

// Setup dates
let now = NSDate()
let next = NSDate(timeInterval: 14400)

// This formats 24-hr preferences correctly
let dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = .MediumStyle
dateFormatter.timeStyle = .LongStyle
let str = dateFormatter.stringFromDate(now)
NSLog("Date: \(str)")
        
// This ignores the 24-hr preference toggle
let dateIntervalFormatter = NSDateIntervalFormatter()
dateIntervalFormatter.dateStyle = .MediumStyle
dateIntervalFormatter.timeStyle = .LongStyle
let strInterval = dateIntervalFormatter.stringFromDate(now, toDate: next)
NSLog("DateInterval: \(strInterval)")

Expected Results:
NSDateIntervalFormatter should format the times using the 24hr format or 12hr format depending on device setting.

Actual Results:
NSDateIntervalFormatter uses 12hr time format

Version:
iOS 9.2.1 (13D15)

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!