Getting the date format for the current locale

When I first came across the defaultTimeLocale constant in System.Locale , I assumed that it should contain the default TimeLocale for the current locale.

After some attempts, I realized that it always contains the same constants and, looking at the source code of System.Locale , I quickly discovered that this is actually only a constant. (Later I realized that the type also tells me this. Since defaultTimeLocale not an IO value and does not accept any arguments, it must be constant.)

How in Haskell can I get the current TimeLocale relative to the current language?

+6
source share
1 answer
 System.CurrentLocale.currentLocale :: IO TimeLocale 

from the current-locale package looks appropriate.

I have not tested. Considering the source code, it should work. I really don’t really like it, since four date (!) Subprocesses appear under it, Which is pretty tedious for this simple task, IMHO.

It may be possible to rewrite it to use some C or POSIX functions.

+1
source

Source: https://habr.com/ru/post/981372/