Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decimal.parse and .format #9637

Merged
merged 11 commits into from
Apr 11, 2024
Merged

Decimal.parse and .format #9637

merged 11 commits into from
Apr 11, 2024

Conversation

GregoryTravis
Copy link
Contributor

@GregoryTravis GregoryTravis commented Apr 4, 2024

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@GregoryTravis GregoryTravis marked this pull request as ready for review April 4, 2024 20:59
@GregoryTravis GregoryTravis added the CI: No changelog needed Do not require a changelog entry for this PR. label Apr 4, 2024
@GregoryTravis GregoryTravis marked this pull request as draft April 4, 2024 21:04
@GregoryTravis
Copy link
Contributor Author

Converting this back to draft to explore using DecimalFormat.

@GregoryTravis GregoryTravis changed the title Tests for Decimal.to_text etc. Decimal.parse and .format:w Apr 5, 2024
@GregoryTravis GregoryTravis changed the title Decimal.parse and .format:w Decimal.parse and .format Apr 5, 2024
@GregoryTravis GregoryTravis marked this pull request as ready for review April 5, 2024 19:27
@GregoryTravis GregoryTravis removed the CI: No changelog needed Do not require a changelog entry for this PR. label Apr 5, 2024
Comment on lines +674 to +687
d.format . should_equal "123,456,789.87654"
d.format locale=Locale.italy . should_equal "123.456.789,87654"
d.format format="#,###.##" . should_equal "123,456,789.88"
d.format format="#,###.##" locale=Locale.italy . should_equal "123.456.789,88"
d.format format="#,##.##" . should_equal "1,23,45,67,89.88"
d.format format="#,##.##" locale=Locale.italy . should_equal "1.23.45.67.89,88"

group_builder.specify "should parse correctly" <|
Decimal.parse "123456789.87654" . should_equal 123456789.87654
Decimal.parse "123,456,789.87654" locale=Locale.default . should_equal 123456789.87654
Decimal.parse "123,456,789.87654" locale=Locale.us . should_equal 123456789.87654
Decimal.parse "123.456.789,87654" locale=Locale.italy . should_equal 123456789.87654
Decimal.parse "123,456,789.87654" locale=Locale.italy . should_equal 123.456
Decimal.parse "123.456.789,87654" locale=Locale.us . should_equal 123.456
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we should allow setting the custom format in parse as well.

What if I have a string like 1.23.45.67.89,88 (that I got from somewhere) and want to parse it?

But that can be done in future iterations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

@radeusgd radeusgd left a comment

Choose a reason for hiding this comment

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

Looks good to me

@GregoryTravis GregoryTravis merged commit 9ac85b9 into develop Apr 11, 2024
36 checks passed
@GregoryTravis GregoryTravis deleted the wip/gmt/8982-to-text branch April 11, 2024 13:30
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