Skip to content

Hour-override isn't respected when formatting date #301

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

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

itingliu
Copy link
Contributor

We wrongly returned the entire pref dictionary instead of the demanded value.

I did not want to spend too much time adding a test since this is dependent on the the autoupdating current locale. I did verify the following test failed before but passed after the fix.

- (void)test24HourOverride {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setLocale:[NSLocale autoupdatingCurrentLocale]];
    [formatter setLocalizedDateFormatFromTemplate:@"Jmm"];

    NSString *dateFormat = formatter.dateFormat;
    XCTAssertEqualObjects(dateFormat, @"HH:mm");
}

…ows 12 hour format)

We wrongly returned the entire pref dictionary instead of the demanded value.

I did not want to spend too much time adding a test since this is dependent on the the autoupdating current locale. I did verify the following test failed before but passed after the fix.

```Obj-C
- (void)test24HourOverride {
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setLocale:[NSLocale autoupdatingCurrentLocale]];
    [formatter setLocalizedDateFormatFromTemplate:@"Jmm"];

    NSString *dateFormat = formatter.dateFormat;
    XCTAssertEqualObjects(dateFormat, @"HH:mm");
}
```
@itingliu
Copy link
Contributor Author

@swift-ci please test

@itingliu itingliu requested a review from parkera October 25, 2023 23:22
@iCharlesHu
Copy link
Contributor

Linux failure is fixed in swiftlang/swift-syntax#2312

Hopefully we'll get a new snapshot soon

@itingliu itingliu merged commit 9d196fd into swiftlang:main Oct 26, 2023
@itingliu itingliu deleted the locale-autoupdating-pref branch October 26, 2023 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants