Repository navigation
Conversation
…itch DateFormatMigration rebuilt the locale from its identifier, which drops the system hour-cycle override: on a 24-hour region with the 12-hour switch on, no formatter could parse the stored value.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the legacy date-migration change that adds preference-aware parsing.
No open issues 🎉
What changed in this PR
This PR fixes legacy date migration for values affected by the system 12/24-hour setting, allowing previously unrecognized dates to be converted to the SDK’s UTC storage format.
Changes:
- Tries
Locale.currentfirst to preserve the current system hour-cycle preference. - Updates the formatter helper to accept
Localeinstances while retaining all three existing fallbacks.
| File | Description |
|---|---|
Mindbox/Utilities/Migrations/ImplementationOfMigrations/DateFormatMigration.swift |
Adds preference-aware parsing before the existing locale and explicit hour-cycle fallbacks. |
Review effort: Balanced
Contributor
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DateFormatMigrationconverts dates that old SDK versions stored in the localized.fullformat. It did not recognize a value written on a device whose region uses the 24-hour clock while the system 12-hour switch is on, for exampleen_KZwith "4:13:20 AM".Why: the migration rebuilt the locale from
Locale.current.identifier, and the identifier does not carry the system hour-cycle switch. The three formatters it tried had these time patterns foren_KZ:hours=h23:HH:mm:ss;hours=h12:h:mm:ss B(day periods, not AM/PM).None of them parses
h:mm:ss a, soisNeededwasfalse, the value stayed in the legacy format and the date was read asnil.The fix adds one more formatter, tried first:
Locale.currentas it is, which keeps the system switch. The three existing formatters stay as fallbacks.Not covered: a value written with the 12-hour switch on and read after the user turned it off, in a 24-hour region. It still stays unconverted.
Checked on a simulator with
en_KZand the 12-hour switch on: three tests ofDateFormatMigrationTestsfailed before the change (isNeededTrueWhenLegacyValuePresent,runConvertsLegacyInstallationDateAndKeepsIsInstalledStable,runConvertsAllSixKeys), all 11 pass with it. No new test: these three already cover the case, but only on a machine with such settings.Not checked: the full unit test run, and the suite on a branch cut from
develop— it was run with the same change on top of another branch, where the file is identical.