button-card icon indicating copy to clipboard operation
button-card copied to clipboard

Incorrect timezone when displaying time sensor via button-card

Open Spirituss opened this issue 3 years ago • 1 comments

Checklist

  • [*] I updated the card to the latest version available
  • [*] I cleared the cache of my browser

Describe the bug A clear and concise description of what the bug is. Button-card shows time sensor with UTC time zone while it uses another one. You can see correct timezone in the sensor card below.

Version of the card Version: 3.4.2

To Reproduce This is the configuration I used:

                          - name: Time
                            type: custom:button-card
                            color_type: icon
                            show_state: true
                            tap_action:
                              action: more-info
                            show_icon: false  

Screenshots If applicable, add screenshots to help explain your problem. Upper circle: Screen Shot 2022-02-01 at 15 44 55

Expected behavior A clear and concise description of what you expected to happen. Lower circle: Screen Shot 2022-02-01 at 15 44 55

Desktop (please complete the following information):

  • Browser [e.g. chrome, safari] Opera
  • Version [e.g. 22] 83.0.4254.27

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

Spirituss avatar Feb 01 '22 13:02 Spirituss

It displays the raw state, I don't act on the state at all in button-card for time states. You'll have to do it yourself using state_display

Eg:

state_display: |
  [[[
    let td = new Date(entity.state);
    return `${td.toLocaleString("en-US", {hour12: false, weekday: "long", day: "2-digit", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit"})}`;
  ]]]

RomRider avatar Mar 15 '22 19:03 RomRider