ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.73k stars 376 forks source link

The Load Game list display file's date in a wrong format #5287

Open Arthusppp opened 2 years ago

Arthusppp commented 2 years ago

Preliminary checks

Platform

Windows

Describe the bug

I have set the Polish language. My Windows uses Polish culture. And still I can see wrong format date in the Load Game window:

image

I suppose, the fheroes2 could use the game language or the user OS culture setting.

Save file

To reproduce - pls use non-English language. And then, open the Game Load window and see the list of the files.

Additional info

No response

Arthusppp commented 2 years ago

As far as I can see, the text is set here: image

zenseii commented 2 years ago

I suppose, the fheroes2 could use the game language or the user OS culture setting.

I believe using OS settings is out of the question since there are many different systems supported like Switch or PS Vita and they don't necessarily have these systems in place, sort of like how setting the game language according to your OS settings isn't easily implemented from what I've read from previous discussions.

Arthusppp commented 2 years ago

Then maybe sth like: if game language is Polish, then use location "pl_PL"? Blind guess...

ihhub commented 1 year ago

Hi @oleg-derevenetz , what do you think about feasibility to use locale (language and proper encoding) to solve issue? Do you see any possible problems?

oleg-derevenetz commented 1 year ago

Hi @ihhub

Do you see any possible problems?

Yes. The problem with the locale is that it is a global state and it affects a lot of things - not just formatting, but also parsing. For example, it affects std::isalpha(), std::isalnum(), std::tolower()/std::toupper(), etc, etc, so the results may unexpectedly differ from the default "C" locale. Since it is a global state, it is quite dangerous to manipulate it in a multithreaded code. Some functions from std allow specifying the locale as a parameter, but std::strftime() does not.