4 ms·
If you use <input type=time>, the browser uses locale or user regional preferences… even if the app is in an application domain (e.g. medicine, military, scienc
by skissane 1y ago
If you use <input type=time>, the browser uses locale or user regional preferences… even if the app is in an application domain (e.g. medicine, military, science) where 24h is preferred even in 12h-predominant locales. There is no way for the app to say to the browser “this time field should be 24h in all locales”, the only option is to build a custom time field
I asked the HTML spec editors to fix this, but thus far they haven’t: https://github.com/whatwg/html/issues/6698 https://github.com/whatwg/html/issues/6698
- lxgr 1y agoMy issue is more with outputs than inputs (although the latter are also annoying to me in 12-hour format).
- skissane 1y agoOperating systems generally allow user override of locale settings, and browsers generally respect that; I use a locale which officially has 12 hour time as its standard (Australian English), and I always override it to 24 hour time in user preferences (although Australia is rather inconsistent, e.g. in Sydney, train services use 24 hour time; in Melbourne, the metro trains use 12 hour time but the regional services use 24 hour time)
- lxgr 1y agoInteresting, so you're saying that that OS-level time preference is available via JavaScript? I wasn't able to figure out how to query that in a little bit of trying, so I assumed there was no API for it. If there actually is, I'm now even more upset at that log web UI.
- skissane 1y agoWell, if you run this Javascript: 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.
- lxgr 1y ago> It should return the current time, formatted according to your locale and user preferences. 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.)
- skissane 1y agoI have no idea what is going on then… works for me maybe has something to do with OS or browser versions? or maybe (for some reason) this works for some locales but not others?
- o11c 1y agoIt gets worse. 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.