I asked the HTML spec editors to fix this, but thus far they haven’t: https://github.com/whatwg/html/issues/6698
If there actually is, I'm now even more upset at that log web UI.
Intl.DateTimeFormat([],{"timeStyle":"medium"}).format(new Date())
It should return the current time, formatted according to your locale and user preferences.By contrast, this should return it formatted with the defaults for your locale, ignoring your user preferences:
Intl.DateTimeFormat(navigator.language,{"timeStyle":"medium"}).format(new Date())
For me, the first returns 24 hour time and the second returns 12 hour time. Because 12 hour time is default for my primary locale (en-AU), but I override it to 24 hour time in my macOS settings.I know the same works on Windows, and I’m sure it works on Linux too, just the way you configure it is different for each OS.
It does not for me! (I get 12 hour based time in Safari, Firefox, and Chrome, despite having 24 hours configured at the macOS system level.)
maybe has something to do with OS or browser versions?
or maybe (for some reason) this works for some locales but not others?
Some browser APIs respect `LC_TIME`. Others say "fuck standards, I'm using `LC_MESSAGES`".
This means that if those locales differ about say, y/m/d ordering, it is quite possible for the way the browser formats a date to be different than the way it parses the date.
A plus would be showing both.
In firefox you can try it out in about:preferences by setting en-CA as the topmost option in "Choose your preferred language for displaying pages"
And I just checked, firefox is capable of understanding system-wide split locale settings, if you only want LC_TIME
localectl set-locale en_US.UTF-8
localectl set-locale LC_TIME=en_CA.UTF-8
and dates will format, but currencies, addresses, etc will notThat's unfortunate, but then wouldn't the sane way for localization-aware software be to ask the user and not make any such assumptions?
> Assuming you're using the en-US locale, have you tried using the en-CA locale? It has ISO8601 formatted dates, and is otherwise pretty similar to the en-US locale.
Thanks, I'll give that a try tomorrow! If my log exploring UI of, well, not quite choice actually respects that, I'll be very grateful :)
On Linux you can mix and match via LC_*= environmental variables, but that appears to be complexity the browser vendors didn't expose in their UI.
The sane way for any localization-aware software is to use the standard knobs that the user already has for setting such preferences. Which would be the appropriate LC_* in Unix and the corresponding user settings on Windows/macOS.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
If nothing else, selecting UTC should be a very strong hint to any UI that I am capable of parsing YYYY-MM-DD and 24 hour times.