Skip to content

MOBILE-182: Pin DateFormatter locale to fix dateTimeUtc on InAppShowFailure#706

Merged
Vailence merged 4 commits into
developfrom
feature/MOBILE-182
May 27, 2026
Merged

MOBILE-182: Pin DateFormatter locale to fix dateTimeUtc on InAppShowFailure#706
Vailence merged 4 commits into
developfrom
feature/MOBILE-182

Conversation

@Vailence
Copy link
Copy Markdown
Collaborator

@Vailence Vailence commented May 20, 2026

Ticket: https://tracker.yandex.ru/MOBILE-182

Summary

InappShowFailureManager сериализует dateTimeUtc через Date.toString(withFormat: .utc). Без Locale(identifier: "en_US_POSIX") форматтер на устройствах с 12-часовой региональной настройкой подменяет HH:mm:ss на h:mm:ss a и формирует невалидную для бэкенда строку. Запинили локаль на всех форматтерах в MindboxLogger и схлопнули дублирующий ISO-8601 в Mindbox/Extensions/Date+Extensions.swift в один источник правды.

Type of Change

  • Bug fix

Changes

  • Запинен Locale(identifier: "en_US_POSIX") на всех DateFormatter в MindboxLogger/Shared/Extensions/Date+Extension.swift и String+Extensions.swift
  • Исправлен hh:mm:ss.SSSSHH:mm:ss.SSSS в Date.dateFormatter (был 12-часовым)
  • Добавлен DateFormat.utcWithMillis для парсинга миллисекундных payload'ов
  • Удалён дублирующий Mindbox/Extensions/Date+Extensions.swift; DateTime.decodeWithFormat и MindboxWebViewFacade переведены на унифицированный String.toDate(withFormat:) / Date.toString(withFormat:)
  • InappShowFailureManagerTests локальный makeUTCFormatter() заменён на String.toDate(withFormat: .utc)
  • Новый Swift Testing-сьют DateFormatTests фиксирует литералы .utc / .api / .utcWithMillis, парс round-trip и явный регресс-гард на 12h-leak
  • Shape-assert в testAddFailure_setsDateTimeUtcInsideMethod: длина 20, суффикс Z, нет AM/PM/пробелов, regex ^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$ — контракт исходящего поля привязан к литералу, а не только к round-trip через тот же парсер

Testing

  • Unit tests added/updated
  • Manual testing performed

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes an iOS locale-dependent DateFormatter issue that could generate invalid dateTimeUtc strings (12-hour format leaking into a fixed UTC contract), and consolidates ISO-8601 date parsing/formatting into MindboxLogger as the single source of truth.

Changes:

  • Pinned Locale(identifier: "en_US_POSIX") for all relevant DateFormatter usage in MindboxLogger and corrected a 12-hour (hh) format to 24-hour (HH) where appropriate.
  • Unified ISO-8601 parsing by routing DateTime decoding through String.toDate(withFormat:) with a new .utcWithMillis fallback, and removed the duplicate Mindbox/Extensions/Date+Extensions.swift.
  • Strengthened regression coverage with a new Swift Testing suite (DateFormatTests) and stricter shape assertions in InappShowFailureManagerTests.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
MindboxTests/MindboxLogger/DateFormatTests.swift Adds Swift Testing coverage for UTC/API literals, millis parsing, and a regression guard against 12h-format leakage.
MindboxTests/InApp/Tests/InappShowFailureManagerTests.swift Updates parsing to shared formatter utilities and asserts the outbound dateTimeUtc contract shape.
MindboxTests/Extensions/Tag+Extensions.swift Adds a dateFormatting tag used by the new test suite.
MindboxLogger/Shared/Extensions/String+Extensions.swift Adds .utcWithMillis and pins POSIX locale for parsing via toDate(withFormat:).
MindboxLogger/Shared/Extensions/Date+Extension.swift Pins POSIX locale for formatting and fixes a 12h (hh) formatter to 24h (HH).
Mindbox/Model/Common/MBDate.swift Switches DateTime decoding to unified logger parsing with millis fallback.
Mindbox/InAppMessages/Presentation/Views/WebView/Debug/MindboxWebViewFacade.swift Switches first-init timestamp serialization to toString(withFormat: .utc).
Mindbox/Extensions/Date+Extensions.swift Removes duplicated ISO-8601 parsing/formatting implementation.
Mindbox.xcodeproj/project.pbxproj Updates Xcode project references (adds new tests, removes deleted date extension file).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@justSmK
Copy link
Copy Markdown
Collaborator

justSmK commented May 21, 2026

У тебя коммиты с номером задачи и названием ветки разъехались. Надо бы поправить

Comment thread Mindbox.xcodeproj/project.pbxproj Outdated
@Vailence Vailence force-pushed the feature/MOBILE-182 branch from 6cc7d2c to 00db4dd Compare May 21, 2026 15:53
@Vailence Vailence changed the title MOBILE-164: Pin DateFormatter locale to fix dateTimeUtc on InAppShowFailure MOBILE-182: Pin DateFormatter locale to fix dateTimeUtc on InAppShowFailure May 21, 2026
@Vailence Vailence merged commit 0916fe1 into develop May 27, 2026
6 checks passed
@Vailence Vailence deleted the feature/MOBILE-182 branch May 27, 2026 05:48
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.

3 participants