diff --git a/README.md b/README.md index 88891b7..9302e25 100644 --- a/README.md +++ b/README.md @@ -368,7 +368,7 @@ Inside the javascript code, you'll have access to those variables: - `helpers.formatShortDateTime(datetime)`: August 9, 2021, 8:23:15 AM - `helpers.formatShortDateTimeWithYear(datetime)`: 9/8/2021, 8:23 AM - Example: `return helpers.formatDateTime(entity.attribute.last_changed)` - - `helpers.relativeTime(date)`: Returns an lit-html template which will render a relative time and update automatically. `date` should be a string. Usage for eg.: `return helpers.relativeTime(entity.last_changed)` + - `helpers.relativeTime(date, capitalize? = false)`: Returns an lit-html template which will render a relative time and update automatically. `date` should be a string. `capitalize` is an optional boolean, if set to `true`, the first letter will be uppercase. Usage for eg.: `return helpers.relativeTime(entity.last_changed)` See [here](#templates-support) for some examples or [here](#custom-fields) for some crazy advanced stuff using templates! diff --git a/src/button-card.ts b/src/button-card.ts index a96278e..dc87ac3 100644 --- a/src/button-card.ts +++ b/src/button-card.ts @@ -337,7 +337,7 @@ class ButtonCard extends LitElement { ); } - private _relativeTime(date: string | undefined) { + private _relativeTime(date: string | undefined, capitalize: boolean = false) { if (date) { return html` `; }