We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tested in Xcode 11.1 with Swift 5
md5: d7faf79af167c9fe80a07f4bf22e38c9
Issue Description:
Using a simple code snippet, I can demonstrate that the year returned from DateFormatter when using Pashto locale is incorrect.
let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: "ps") dateFormatter.setLocalizedDateFormatFromTemplate("y") let yearString = dateFormatter.string(from: Date())
The value of yearString is:
"AP ۱۳۹۸"
Expected output (as seen for example here: https://nsdateformatter.com/):
"۲۰۱۹"
The text was updated successfully, but these errors were encountered:
@swift-ci create
Sorry, something went wrong.
If the format is set via the dateFormat property then it works correctly, however when using the template 'y' the date format used is 'G y' where G is the era 'AD' or 'BC' etc - see http://www.unicode.org/reports/tr35/tr35-31/tr35-dates.html#Date_Format_Patterns
dateFormat
y'
'G y'
G
Note the .dateFormat property is how https://nsdateformatter.com/ works.
.dateFormat
$ cat 11775.swift import Foundation let dateFormatter = DateFormatter() dateFormatter.locale = Locale(identifier: "ps") dateFormatter.dateFormat = "y" print("Using 'y':", dateFormatter.string(from: Date())) dateFormatter.setLocalizedDateFormatFromTemplate("y") let format = dateFormatter.dateFormat! print("Template 'y' give dateFormat: \(format)") print("Using '\(format)':", dateFormatter.string(from: Date())) $ swift 11775.swift Using 'y': ۱۳۹۸ Template 'y' give dateFormat: G y Using 'G y': AP ۱۳۹۸
So the era is probably still incorrect although this is handled by the underlying ICU library
Comment by Petr Kubista (JIRA)
I believe I originally discovered this when using the following:
let dateFormatter = DateFormatter() dateFormatter.dateStyle = .medium
No branches or pull requests
Environment
Tested in Xcode 11.1 with Swift 5
Additional Detail from JIRA
md5: d7faf79af167c9fe80a07f4bf22e38c9
Issue Description:
Using a simple code snippet, I can demonstrate that the year returned from DateFormatter when using Pashto locale is incorrect.
The value of yearString is:
"AP ۱۳۹۸"
Expected output (as seen for example here: https://nsdateformatter.com/):
"۲۰۱۹"
The text was updated successfully, but these errors were encountered: