-
Notifications
You must be signed in to change notification settings - Fork 1.2k
SR-5837: Fix dateFormat bug in DateFormatter #1200
New issue
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
Conversation
@swift-ci please test |
@swift-ci please test |
I've updated the test coverage for this issue, in doing so I found a difference in behaviour in the construction of the This issue can be seen if you set the Here is an example: let f = DateFormatter()
f.dateStyle = .medium
f.timeStyle = .long
f.dateFormat In a playground |
@swift-ci please test |
@parkera any thoughts about this difference in CF behaviour with |
Ive seen this issue with ICU on Linux even using a C program interfacing directly to ICU bypassing Swift / CoreFoundation. |
One of these days we're going to have to enforce a specific version of ICU to use with swift-corelibs-foundation. In the past there were objections to this idea since it would increase the size of the distribution, but that may not matter as much any more. |
The swift build script actually has support for building ICU as part of the build although However in my testing I tested upto 57.1 (which was reasonably recent) and it still exhibited these issues on Linux. Does Apple do any customisation for its build of |
Yah, you can see the Apple ICU release here: https://opensource.apple.com/release/macos-10125.html |
@swift-ci please test and merge |
In a playground if you do the following:
f.dateFormat
at this point is equal to "MMMM d, y 'at' h:mm:ss a z"However if you do the same in Foundation the f.dateFormat is equal to "" this is because whenever you set the Style properties dateFormat is being set to nil but it's not then reassigned a new value at that point. The code handles this nil value by assigning dateFormat the value of "" but this is not the correct value.
The expected behaviour is that when you set the Style properties the dateFormat property is then also reassigned the correct value based on the value you assigned to the Style properties.
This PR fixes this behaviour and ensures dateFormat is being set whenever the the Style properties are being set. I've also opened a bug for this which you can find here