-
Notifications
You must be signed in to change notification settings - Fork 95
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
Issue in std::basic_string<charT> to_simple_string_type(time_duration td) with locales #200
Comments
to_simple_string ignores locales, so it's not really the right tool for the job. Have a look at the following: https://github.com/boostorg/date_time/blob/develop/test/posix_time/testtime_facet.cpp |
Yes, I know the others options to do this job. But, as boost::posix_time::to_iso_extended_wstring exits and is publicity accesible; I would like to use it. |
From the initial problem report it seemed like it wasn't just wstring with the problem. And for sure the code here has no dependency on locales -- in particular the global one -- which is a property I'd like to keep. If we wanted a locale based solution it should be an overload. |
I think these public functions should not dependencies on locales. But as ISO is always in classic locale, I think it should be good to set imbue(std::locale::classic()) in the function to_simple_string_type to solve future problems with parse ISO string in other applications or languages. |
The classic locale doesn't have anything to do with ISO time representations -- as far as I know, you'll never get ISO out of time_put/get without forcing the format. The only thing that could be used there are the punctuation chars, which is the original issue you're having. So maybe if there was a tweak we could make it would be that the separators be a defaulted parameter to the function. |
Ok, that should be enough. |
I would like that next code will generate correct output:
Current output MSVC 16.11.7 Expected output: |
There is a problem std::basic_string to_simple_string_type(time_duration td) if application doesn't use the locale("C").
If you use spanish locale the result of this function is like this one:
2020-11-03T09:26:04.966.395
where the second 'dot' is wrong because is the miles signal in spanish locale.
I propose to correct it, use next code:
Best regards
The text was updated successfully, but these errors were encountered: