relative-time-element icon indicating copy to clipboard operation
relative-time-element copied to clipboard

Render 12/24 hour format according to user's preference

Open silverwind opened this issue 2 months ago • 5 comments

Fixes: https://github.com/github/relative-time-element/issues/276

In my testing on MacOS, neither Chrome, Safari or Firefox did follow the OS's "24-hour time" setting, so from what I gather, browsers seem to try to determine this based on locale only currently.

Before (with 24h preference):

Screenshot 2025-10-28 at 00 52 56

After (with 24h preference):

Screenshot 2025-10-28 at 00 52 37

With user config override: Screenshot 2025-10-28 at 01 45 04

silverwind avatar Oct 28 '25 00:10 silverwind

@silverwind I'm not entirely sure, but would it be possible to add some tests as well?

siddharthkp avatar Nov 10 '25 15:11 siddharthkp

Yes, some tests should be possible and given that they run in Chromium they might actually return some useful results.

silverwind avatar Nov 10 '25 15:11 silverwind

Maybe @keithamus also has some feedback.

silverwind avatar Nov 10 '25 15:11 silverwind

Also, I'm certain now that Intl.Locale.prototype.getHourCycles is a flawed approach that will not work reliably because it obtains the hourCycle preference for a given locale which not necessarily matches what the user has configured. It fails in my case where I have en-US configured as OS locale but have 24h cycle set in the OS. In https://stackoverflow.com/questions/27647918, there are various workarounds being discussed and all of them basically rely on checking how dates as being formatted as string.

silverwind avatar Nov 10 '25 15:11 silverwind

Yes, some tests should be possible and given that they run in Chromium they might actually return some useful results.

Sounds good! Assigning it back to you then :)

No obligation, of course! Let me know if you'd like one of us to pick up the tests instead

siddharthkp avatar Nov 11 '25 05:11 siddharthkp