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

Support comma as decimal marker, spaces as thousands separator #19

Open
todofixthis opened this issue Mar 10, 2017 · 0 comments
Open

Support comma as decimal marker, spaces as thousands separator #19

todofixthis opened this issue Mar 10, 2017 · 0 comments

Comments

@todofixthis
Copy link
Contributor

To conform to international standards, the Decimal filter should handle commas and spaces:

From https://en.wikipedia.org/wiki/SI:

The 10th resolution of CGPM in 2003 declared that "the symbol for the decimal marker shall be either the point on the line or the comma on the line." In practice, the decimal point is used in English-speaking countries and most of Asia, and the comma in most of Latin America and in continental European countries.

Spaces should be used as a thousands separator (1 000 000) in contrast to commas or periods (1,000,000 or 1.000.000) to reduce confusion resulting from the variation between these forms in different countries.

Examples:

# Valid
Decimal().apply('0.54')
Decimal().apply('0,54')
Decimal().apply('.54')
Decimal().apply(',54')
Decimal().apply('54.')
Decimal().apply('54,')
Decimal().apply('1 000 000.54')
Decimal().apply('1 000 000,54')

# Not valid - multiple decimal markers
Decimal().apply('0.5.4')
Decimal().apply('0,5,4')
Decimal().apply('2,000.00')

# Not valid - thousands separator used incorrectly
Decimal().apply('1 000 0,0)
Decimal().apply('0,5 4')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant