-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Allow customization of time format #22339
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -515,6 +515,7 @@ export interface TileCardConfig extends LovelaceCardConfig { | |
icon_hold_action?: ActionConfig; | ||
icon_double_tap_action?: ActionConfig; | ||
features?: LovelaceCardFeatureConfig[]; | ||
format?: TimestampRenderingFormat; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should also add this to the struct in |
||
} | ||
|
||
export interface HeadingCardConfig extends LovelaceCardConfig { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import type { UpdateEntity } from "../data/update"; | |
import { computeUpdateStateDisplay } from "../data/update"; | ||
import "../panels/lovelace/components/hui-timestamp-display"; | ||
import type { HomeAssistant } from "../types"; | ||
import type { TimestampRenderingFormat } from "../panels/lovelace/components/types"; | ||
|
||
const TIMESTAMP_STATE_DOMAINS = ["button", "input_button", "scene"]; | ||
|
||
|
@@ -59,6 +60,8 @@ class StateDisplay extends LitElement { | |
|
||
@property({ attribute: false }) public name?: string; | ||
|
||
@property({ attribute: false }) public format?: TimestampRenderingFormat; | ||
|
||
@property({ type: Boolean, attribute: "dash-unavailable" }) | ||
public dashUnavailable?: boolean; | ||
|
||
|
@@ -90,7 +93,7 @@ class StateDisplay extends LitElement { | |
<hui-timestamp-display | ||
.hass=${this.hass} | ||
.ts=${new Date(stateObj.state)} | ||
format="relative" | ||
.format=${this.format} | ||
capitalize | ||
></hui-timestamp-display> | ||
`; | ||
|
@@ -133,6 +136,7 @@ class StateDisplay extends LitElement { | |
<ha-relative-time | ||
.hass=${this.hass} | ||
.datetime=${relativeDateTime} | ||
.format=${this.format} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would not be used ever, as we already would have returned the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to check this, but I'm pretty sure I saw this being reached at some point during my testing. I'll investigate a bit more and provide any pertinent data. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely being hit frequently in my intended use-case (binary motion sensors displaying the last changed time). The original Note the new formats are opt-in; when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the removal of the code from the previous comment it does. |
||
capitalize | ||
></ha-relative-time> | ||
`; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also add this to the struct in
hui-entity-badge-editor