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

os/strftime doesn't respect environment variables. #1443

Closed
amano-kenji opened this issue May 6, 2024 · 3 comments
Closed

os/strftime doesn't respect environment variables. #1443

amano-kenji opened this issue May 6, 2024 · 3 comments

Comments

@amano-kenji
Copy link
Contributor

amano-kenji commented May 6, 2024

%a of os/strftime can change according to locale.

Setting locale through environment variables like LANG and LC_ALL doesn't work.

Even though my system uses glibc, os/strftime doesn't respect environment variables.

@amano-kenji amano-kenji changed the title os/setlocale for os/strftime. os/strftime doesn't respect environment variables. May 6, 2024
@bakpakin
Copy link
Member

I don't know if there is something Janet should do here besides expose setlocale - we don't do anything to set or unset locales from environment variables, so if your OS or libc is not doing it, then Janet isn't doing it either.

@bakpakin
Copy link
Member

Add os/setlocale as a very bare bones wrapper around setlocale. I spent some time trying to make thread local setlocale work, but each platform has it's own way of doing it and it was hard to make it consistent.

Example with os/strftime:

(os/setlocale (os/getenv "LC_ALL" "C")) # call at script start
(print (os/strftime "%A %c" (os/time)))

@amano-kenji
Copy link
Contributor Author

Thread local?

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

2 participants