Skip to content

MOBILE-0000: Parse legacy dates written with the system 12/24-hour switch - #858

Open
Vailence wants to merge 1 commit into
developfrom
feature/MOBILE-0000-date-migration-hour-cycle
Open

Vailence wants to merge 1 commit into
developfrom
feature/MOBILE-0000-date-migration-hour-cycle

Conversation

@Vailence

Copy link
Copy Markdown
Collaborator

DateFormatMigration converts dates that old SDK versions stored in the localized .full format. 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 example en_KZ with "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 for en_KZ:

  • the base locale and hours=h23: HH:mm:ss;
  • hours=h12: h:mm:ss B (day periods, not AM/PM).

None of them parses h:mm:ss a, so isNeeded was false, the value stayed in the legacy format and the date was read as nil.

The fix adds one more formatter, tried first: Locale.current as 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_KZ and the 12-hour switch on: three tests of DateFormatMigrationTests failed 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.

…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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 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.current first to preserve the current system hour-cycle preference.
  • Updates the formatter helper to accept Locale instances 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

@github-actions

Copy link
Copy Markdown
Contributor
TestsPassed ✅SkippedFailedTime ⏱
Unit tests report3108 ran3108 ✅3m 20s 592ms

This branch has not been deployed

No deployments
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