Skip to content

Commit

Permalink
Handle deprecated API in DatePickerController (#2089)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischreiber authored Sep 11, 2024
1 parent f7b1b2e commit 0fadbee
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions macos/FluentUI/DatePicker/DatePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,17 @@ open class DatePickerController: NSViewController {

// In this case, we want to use Chinese numerals instead of western
// Setting dateStyle to .long before setting the dateFormat will achieve this
if calendar.identifier == .chinese && calendar.locale?.languageCode == "zh" {
formatter.dateStyle = .long
if calendar.identifier == .chinese {
let languageCode: String?
if #available(macOS 13.0, *) {
languageCode = calendar.locale?.language.languageCode?.identifier
} else {
languageCode = calendar.locale?.languageCode
}
if languageCode == "zh" {
formatter.dateStyle = .long
}
}

formatter.dateFormat = "d"

return formatter
Expand Down

0 comments on commit 0fadbee

Please sign in to comment.