Code Monkey home page Code Monkey logo

Comments (20)

balloob avatar balloob commented on May 13, 2024

The logbook and rising message in the sun card are actually being rendered using browser locale aware formatting. So for you seeing the AM/PM times means that is what your browser prefers. You can check your browser settings using these instructions.

That being said, you're right that it is still inconsistent. It looks like I have hard coded the history to support the 24h system instead of being locale aware.

from core.

michaelarnauts avatar michaelarnauts commented on May 13, 2024

Hmm, strange, my browser is set up for the Dutch language:

image

I also have the same behavior on my Android device. Are your sure it's not the 12h system that's hardcoded?

from core.

michaelarnauts avatar michaelarnauts commented on May 13, 2024

I've digged into it a bit, and don't you need to specify the current locate to the moment library? It seems to be using LT what is the shortcode for locale aware time, but by default moment is using english.

window.hass.uiUtil.formatTime = function(dateObj) {
  return moment(dateObj).format('LT');
};

See http://momentjs.com/docs/#/i18n/changing-locale/

from core.

balloob avatar balloob commented on May 13, 2024

Ah dang, it seems like you're right.

If only Apple would implement toLocaleDateString and toLocaleTimeString, it would make our lives so much easier.

from core.

infamy avatar infamy commented on May 13, 2024

Still present as of 0.20.x

from core.

CoalaJoe avatar CoalaJoe commented on May 13, 2024

Is this still a thing?

from core.

michaelarnauts avatar michaelarnauts commented on May 13, 2024

Yep, still the same.

from core.

CoalaJoe avatar CoalaJoe commented on May 13, 2024

I think moment.js could handle this. But I don't think we want add a new dependency.

from core.

michaelarnauts avatar michaelarnauts commented on May 13, 2024

AFAIK, moment is already a dependency. Check my comment above. It just isn't initialised correctly.

from core.

balloob avatar balloob commented on May 13, 2024

We removed moment, it is way too big for what it does. We use JavaScript
native toLocaleString and toLocaleDateString.

On Wed, Oct 26, 2016 at 10:38 PM, Michaël Arnauts [email protected]
wrote:

AFAIK, moment is already a dependency. Check my comment above. It just
isn't initialised correctly.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#184 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ABYJ2tCH_Hmk_4mNHcQvhTWExJCiYpXrks5q4DjOgaJpZM4FFpdB
.

PaulusSchoutsen.nl
It's nice to be important but it's more important to be nice.

from core.

michaelarnauts avatar michaelarnauts commented on May 13, 2024

Okay, I didn't know that.

from core.

balloob avatar balloob commented on May 13, 2024

The times in the graphs are configured in a different way however.

from core.

CoalaJoe avatar CoalaJoe commented on May 13, 2024

Is there any Polyfill?

from core.

michaelarnauts avatar michaelarnauts commented on May 13, 2024

There seems to be a different implementation between browsers.

  • Firefox takes the topmost language in the browser configuration (nl), and considers that to be the preferred language.
  • Chrome takes the language of the installed Chrome version (en), and considers that to be the preferred language, even though nl is at the top of my language configuration list.
  • I'm not sure what Edge and Internet Explorer 11 do.

Firefox:

> navigator.language
"nl"
> navigator.languages
Array [ "nl", "en", "en-US" ]

Chrome:

> navigator.language
"en-US"
> navigator.languages
["nl", "en", "en-US"]

A more general solution could be to use the following line instead of just navigator.language.

    language = navigator.languages ? navigator.languages[0] : navigator.language || navigator.userLanguage;

This picks the first selected language in your settings, and fallbacks to navigator.language or navigator.userLanguage (for old IE versions).

What do you think?

from core.

michaelarnauts avatar michaelarnauts commented on May 13, 2024

According to this page, IE returns the language of the Operating System, what also don't accurately describe the time formatting requested.

Someway, it doesn't feel right to depend the time formatting on the language of the operating system or browser installed. I think a lot of installed browsers in non-english countries can be English, but they don't use AM/PM notation (what seems to be used mainly in US and UK).

from core.

robbiet480 avatar robbiet480 commented on May 13, 2024

Closed via home-assistant/frontend#170!

from core.

sillevl avatar sillevl commented on May 13, 2024

I would like to reopen this issue. home-assistant/frontend#170 Indeed solves part of the problem stated in the start topic. It fixes the date format in the logbook, but not in the state history chart timeline. The problem as shown in the screenshots is still present.

I opened an issue at the home-assistant-polymer project as wel: home-assistant/frontend#196

from core.

fanaticDavid avatar fanaticDavid commented on May 13, 2024

I can confirm I'm still seeing this issue in the timeline pop-over (both in the States UI and the History UI). It seems to have been addressed everywhere else.

Seen in Firefox 51.0.1 set to Dutch (nl) on macOS 10.12.4 bèta.
Same behaviour in Chrome 55.0.2883.95 set to Dutch (nl), as well as in Safari 10.1 (12603.1.20.1) which seems to use the OS language setting (Belgian Dutch).

from core.

emlove avatar emlove commented on May 13, 2024

Agree this should be reopened. home-assistant/frontend#170 is a step in the right direction, but the Google charts time formatting still hasn't been addressed.

from core.

michaelarnauts avatar michaelarnauts commented on May 13, 2024

There is a new issue in the home-assistant-polymer repo: home-assistant/frontend#196
The backend is reporting the time like 2017-02-13T18:38:47.427063+00:00, so the issue lies in the frontend.

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.