Skip to content

iOS: DateFormatter has no fixed locale, breaking non-Gregorian calendars #40

Open

Description

@developerjamiu
// ios/smart_text_flutter/Sources/smart_text_flutter/NSDataDetectorExtension.swift:88-90
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"

A fixed format string combined with the user's locale produces wrong output under non-Gregorian calendars. A user whose device is set to the Buddhist or Japanese calendar gets a year like 2569 in the rawValue.

This is a well-known iOS pitfall: fixed-format DateFormatter must pin its locale.

Fix: set locale = Locale(identifier: "en_US_POSIX"), or use ISO8601DateFormatter, which is what the format string is imitating.

Found during the v0.4.0 codebase audit.

Activity

  1. added
    bug
    platform: ios
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugplatform: ios

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions