New Date.FormatStyle: Anyway to do 24 hour?

in my experience DateFormatter's
setLocalizedDateFormatFromTemplate(_:) works ok.

This is definitely your friend.

i do not know how to ask it for "user preferred 24 or 12 hour symbol"

The go-to reference for this stuff is Unicode Technical Standard #35. It describes the j and J elements, that do exactly this.

IMPORTANT This only works in the context of date format templates. That is, do this:


not this:

df.dateFormat = "j"

Then again, if you’re working with localised dates then the dateFormat property is nonsense anyway.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple