Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Project cannot be build and if so tests do not pass for regional settings with decimal separators "," #5

@matopeto

Description

@matopeto

Hi @Qata after you resolve #4. I cannot build the project:

Just downloaded code from github, opened Packgage.swift in Xcode 13.2.1 and ran the build.

I got errors:

obrazek

Then I temporary change iOS target from .v8 to .v10 in (to "resolve") the compatibility of .iso8601 value), then i run the tests on (iPhone 11 pro simulator with iOS 15.2 on Xcode 13.2.1 they fails:

Screenshot 2022-02-19 at 21 09 52

They pass OK for region US, but fails for region "Czechia" (maybe problem with decimal/grouping separator)

I tried to replace all Decimal(string: ) initializer with Decimal(string:, locale: Locale(identifier: "en_US") because, json numbers are coded with "." as decimal separator but it not works. Still crash at the same place.

PS: i think you should use Decimal(string: locale:) instead of Decimal(string:) because apple documentations says:

https://developer.apple.com/documentation/foundation/nsdecimalnumber/1409902-init (it is for NSDecimalNumber but i think it applies for Decimal as well)

Discussion
Don’t use this initializer if numericString has a fractional part, since the lack of a locale makes handling the decimal separator ambiguous. The separator is a period in some locales (like in the United States) and a comma in others (such as France).
To parse a numeric string with a fractional part, use init(string:locale:) instead. When working with numeric representations with a known format, pass a fixed locale to ensure consistent results independent of the user’s current device settings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions