Skip to content

Fix remaining FormatStyle caches of autoupdating locales #342

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

Conversation

parkera
Copy link
Contributor

@parkera parkera commented Dec 6, 2023

Fix up remaining issues where we cache a Locale for format styles, and an autoupdating locale will not cause a refreshed format.

Follows up on 18ac5ac (#334 )

Fixes rdar://119010483

…and an autoupdating locale will not cause a refreshed format.

Follows up on 18ac5ac (swiftlang#334)

Fixes rdar://119010483
@parkera
Copy link
Contributor Author

parkera commented Dec 6, 2023

@swift-ci test

Copy link
Contributor

@itingliu itingliu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only one comment regarding the relative formatted. It doesn't look like we are registering preferences with ICU formatter currently anyways, but wanted to check

let formatter = Self.cache.formatter(for: format) {
ICURelativeDateFormatter(uNumberFormatStyle: format.unitsStyle.icuNumberFormatStyle, uRelDateStyle: format.unitsStyle.icuRelativeDateStyle, locale: format.locale, context: format.capitalizationContext.icuContext)
internal static func formatter(for style: Date.RelativeFormatStyle) -> ICURelativeDateFormatter {
let signature = Signature(localeIdentifier: style.locale.identifier, numberFormatStyle: style.unitsStyle.icuNumberFormatStyle?.rawValue, relativeDateStyle: style.unitsStyle.icuRelativeDateStyle.rawValue, context: style.capitalizationContext.icuContext.rawValue)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be the preference-capturing locale identifier to account for, say, custom first weekday? I imagine that information would be useful for calculating relative date in terms of weeks

Copy link
Contributor Author

@parkera parkera Dec 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that may be another bug. I'll file one to check if ICURelativeDateFormatter should be using preference-capturing locale.

@parkera parkera merged commit 1bb0cbb into swiftlang:main Dec 8, 2023
@parkera parkera deleted the parkera/more_autoupdating_locale_fixes branch December 8, 2023 00:07
parkera added a commit to parkera/swift-foundation that referenced this pull request Dec 11, 2023
itingliu pushed a commit to itingliu/swift-foundation that referenced this pull request Dec 12, 2023
…and an autoupdating locale will not cause a refreshed format. (swiftlang#342)

Follows up on 18ac5ac (swiftlang#334)

Fixes rdar://119010483
parkera added a commit that referenced this pull request Dec 18, 2023
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.

2 participants