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
Time formatting not following browser locale settings in state history chart timeline #196
Comments
Can you attach a screenshot of the location where the time is still displayed incorrectly? |
Alright, I see it also now, I didn't hover over the timeline... I'll take a look at it :) |
The other portion is the actual timeline labels. They are currently hard-coded to 24 hours, no matter the locale. This is true anywhere we use google charts. |
It seems you need to initialise the google charts with a language. By default this is This should do the trick, but I'm unable to test since I'm having issues downloading python dependencies... diff --git a/src/components/state-history-charts.html b/src/components/state-history-charts.html
index 3755040..d64e57c 100644
--- a/src/components/state-history-charts.html
+++ b/src/components/state-history-charts.html
@@ -85,6 +85,7 @@ Polymer({
_googleApiLoaded: function () {
window.google.load('visualization', '1', {
packages: ['timeline', 'corechart'],
+ language: window.hassUtil.LANGUAGE,
callback: function () {
this._apiLoaded = true;
}.bind(this), |
The problem is here: https://github.com/home-assistant/home-assistant-polymer/blob/master/src/components/state-history-chart-line.html#L94 (and equivalent for timeline) where the format is hard-coded. As I understand, the reason it's hard-coded is that google charts doesn't have an easy way to display a short time string in the locale preferred way. |
@armills indeed, that's the second issue where the times on the h-axis are forced to 24h. |
Ah you're right. For some reason I was thinking of the other problem. Adding the language will be good. 👍 |
is this still on the map? quite confusing for 24h-formatted users as me in europe :) |
Can anyone please test the solution from @michaelarnauts ? I live in Germany and would like to have the logbook in 24h format, just like the rest of the ui properly does change to 24h when setting the correct language. |
In #847 I'm passing |
That's probably also a good alternative to language: window.hassUtil.LANGUAGE, , but does #847 also fix the logbook/history? Sorry if this is a dumb question |
window.hassUtil.LANGUAGE is not defined. Logbook is already using navigator.language |
There was a hassUtil.LANGUAGE, that took care of some browser differences since navigator.language didn't work the same on all browsers. |
Upgrading to 0.64, new Chart.js timeline no longer using 24 hour style as google charts did: At least for tooltip, I noticed that it is using |
@mcspr please create a new issue for this a we replaced the chart component |
As stated in home-assistant/core#184 (comment), the formatting of time is inconsistent in the state history chart timeline. With browser settings set to 'nl', the time is still formated in am/pm format, not in 24h format.
This problem existed also in the logbook (home-assistant/core#184 (comment)) and was fixed in #170. I believe a similar solution could be build for this issue.
The
window.hassUtil.formatTime
function could be used that was changed in #170 as it takes the locale setting into account when formatting dates and times. (see https://github.com/michaelarnauts/home-assistant-polymer/blob/842c5d5e89960e1bf432b210c84af69ecb424d58/src/util/hass-util.html#L132)The text was updated successfully, but these errors were encountered: