custom-cards / button-card

❇️ Lovelace button-card for home assistant
MIT License
1.93k stars 233 forks source link

helpers.relativeTime(date) doesn't capitalize #735

Closed basbruss closed 1 year ago

basbruss commented 1 year ago

Checklist

Describe the bug The string is not capitalized at the start like it does with other helpers like for example helpers.localize()

Version of the card Version: v4.0.0-dev17

To Reproduce This is the configuration I used:

      - type: custom:button-card
        template: card_title
        label: "test relative time"
        name: >
          [[[
            return helpers.relativeTime(states['sensor.sun_next_dawn'].state)
          ]]]

Screenshots

image

Expected behavior Capitalized string like is done in this card with pure JS

image

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

RomRider commented 1 year ago

I'm using the default component of HA for relative time so that it updates automatically over time, aka <ha-relative-time></ha-relative-time>, I don't control how it's displayed. I don't think there's much I can do about that unfortunately

RomRider commented 1 year ago

Ah, I found there's a @property({ type: Boolean }) public capitalize = false; in the HA object, let me try. If it works, I'll add a parameter to the relativeTime function

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.0.0-dev.18 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

RomRider commented 1 year ago

This fixes it: return helpers.relativeTime(states['sensor.sun_next_dawn'].state, true)

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 4.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: