-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Problem with format function: error with format 'dddo' #3765
Comments
It seems the problem lays in format()'s pattern checking. If you add a space in between as so: format(new Date(2024, 3, 1), 'dd do', {locale: enUS}) it should all work fine. This will however create an output of format(new Date(2024, 3, 1), 'dd do', {locale: enUS}).replace(" ", "") |
Thanks for your response.
This was part of a test case. I do not expect it to be used in real life.
The test should make sure the formatting is compatible with icu4j (java lib), icu4j actually formats this pattern as I expect.
I worked around it by sneaking in a zero width space.
I still think that ‘dddo’ is a valid pattern, albeit unusual. There should be a check if the unescaped ‘o’ is part of an ordinal expression.
Op 15 apr. 2024, om 15:04 heeft Miguel Angelo Bautista ***@***.******@***.***>> het volgende geschreven:
U ontvangt niet vaak e-mail van ***@***.******@***.***>. Meer informatie over waarom dit belangrijk is<https://aka.ms/LearnAboutSenderIdentification>
It seems the problem lays in format()'s pattern checking. If you add a space in between as so:
format(new Date(2024, 3, 1), 'dd do', {locale: enUS})
it should all work fine. This will however create an output of 01 1st. If you want to keep it in one word just use the .replace() function to remove the space in between:
format(new Date(2024, 3, 1), 'dd do', {locale: enUS}).replace(" ", "")
—
Reply to this email directly, view it on GitHub<#3765 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/A67JTXATEP2V4DUN4QKB6ELY5PF6PAVCNFSM6AAAAABGD4TN2GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANJWHAYDMMZQG4>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There is an issue with the format function
The problem
💻 Code demonstrating the problem
🙁 Actual behavior
RangeError: Format string contains an unescaped latin alphabet character
o
🙂 Expected behavior
Output:
011st
Debug information
The text was updated successfully, but these errors were encountered: