NSDateFormatter wrong short date format for language "Norsk nynorsk" and region "Norway" on macOS

When I change the Language & Region in System Preferences on macOS to language "Norsk nynorsk" and region "Norway" the short example date in the System Preferences window is displayed as "01.04.1976, 07:08".

When I create a NSDateFormatter with dateStyle = NSDateFormatterShortStyle and locale = [NSLocale currentLocale] in an application and check the resulting dateFormat of this NSDateFormatter it is "dd/MM/y" and not "dd.MM.y" according to the displayed example date in the System Preferences window.

How can I get the correct dateFormat that macOS uses to display the short example date in the System Preferences window?

Replies

the resulting dateFormat of this NSDateFormatter it is "dd/MM/y" and
not "dd.MM.y"

Hmmm, I’m not seeing this. Here’s what I did:
  1. Using Xcode 12.4 on macOS 11.2.3, I created a tiny test command-line tool (see below).

  2. In System Preferences > Languages & Region, I add “Norsk nynorsk” to the Preferred Languages list on the left.

  3. This asked me whether I wanted to make it primary, and I agreed to that. So that list now shows “Norsk nynorsk” followed by English.

  4. I switched the Region popup to Norway.

  5. I ran my tool from Xcode.

The tool prints:

Code Block
20.04.2021


which is what you want, right?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Code Block
import Foundation
func main() {
let df = DateFormatter()
df.dateStyle = .short
let s = df.string(from: Date())
print(s)
}
main()