Frontend: Not all time formats are correctly shown as 24 hour format

Created on 3 Jul 2019  路  8Comments  路  Source: home-assistant/frontend

Home Assistant release with the issue:

hass.io 0.95.4 but issue has been there since I installed HA back in January

Last working Home Assistant release (if known):
N/A

UI (States or Lovelace UI?):

Various elements of the front end and not specific to Lovelace
Browser and Operating System:

I spent many hours going through the issue.
I have tried Google Chrome, Firefox, and Edge and both Window 10 and Linux (Ubuntu)
Behavior is the same in all OSes and all browsers I tried.
Only small difference is that for Firefox you have to set both OS language in Windows and the browser language to the desired 24 hour compatible locale (in my case en-GB)
This issue does not relate to the browser or any oppinions about how the 12 vs 24 hour display is controlled. It is a report that WHEN the browser and OS is setting the display of time to 24 hour format there are a few places where this simply does not work and 12 hour format is shown no matter how the user is configured

Description of problem:

Here is a walkthrough of the all the places where I have found time to be displayed in the front end. Both where it works and where there is a bug

I have the OS set to en-GB and the browser to en-GB. Behavior is the same both in Windows and Linux and in all browsers I tried (Google Chrome, Firefox, and Edge)

I go through the menus in the left bar top to bottom

On the various tabs in the Overview, the small pop-up you get when you click on a badge or entity is in 24 hour clock. So this works as it should.

The log book is in 12 am/pm format in the left column of all rows. This is clearly a BUG

If I click on an item in the log book the pop-up is again in 24 hour so this is OK

The history is in 24 hour format on the page. So this is OK

But if you hover over the items on the history items with the mouse pointer where you see the states changed and the time it happened, the value you get the time in 12 hour am/pm. This is a BUG

Hass.io -> Snapshot data is in 24 hour format so this is OK

Hass.io -> system log is in 24 hour format so also OK

Developer tools states is all in 24 hour format - both attributes and pop-ups. OK

The logs in the "About screen" are in 12 hour format so this is another BUG
The raw log below is whatever is in the file and shows as 24 hour

Now we can discuss back and forth if the front end should be coded to follow browser or a setting from the backend. In most cases for normal users following the browser is probably fine. It is us geeks that love to have English OS with 24 hour brains that need to have the trouble to change from US to UK.

But the bugs :ant: are objectively bugs in the front end where the devs have missed to use the correct code to get proper time format. And there are 3 places where this is not correct

  • Log book list left column
  • hover over on history bars
  • About screen warnings and errors

Additional information:

Also refer to the discussion at https://community.home-assistant.io/t/24hr-format-instead-of-am-pm-in-europe/45252/56. Ignore the discussion about if the format should follow the browser or be controlled by server config. This bug assumes we follow the client and the bugs are related to the 3 places where this does not work

localization

Most helpful comment

This bug is still relevant and many people keep on raising the issue on the forum

All 8 comments

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 馃憤
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

This bug is still relevant and many people keep on raising the issue on the forum

It sure is. If I have my Hassio interface set to English it displays 12h clock but if I set it to Swedish it's 24h clock. I have my OS and browser set to Swedish as well. Tried multiple browsers and platforms. I would guess that this should be fixed if we had both English US and English UK as option?

My guess is that the problem is in the lack of the guidelines regarding locales, and various people writing their pieces of code used different way of displaying the locale-specific data.

A workaround for e.g. the history graph cards for Chrome is to change the UI language to English Australia. Then the time is displayed in 24 hour format.
The time in the Logbook is still in 12 hour style though...

TobiasZip if you read my original bug report your work around is already listed as the things that works. The bug report is listing all the user interface features where the time format does not change even when you change browser language

I was facing the same problem. Seems like a bunch of calls use the language of the hass user and some others the language of the browser.
As a workaround for for the Logbook, charts etc I am using a userscript to overwrite these functions and force a 24h time:
https://gist.github.com/Smeat/6ad6c958578499b2e71f7dab316223b7

Not pretty, but just in case someone finds this useful

I see 2 solutions here, add English (GB) as language option, or ignore the selected language and always use the browser language. I would prefer the first option.

Was this page helpful?
0 / 5 - 0 ratings