Skip to content
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

Include last 30 min and 2 hours into history page #23848

Open
wants to merge 10 commits into
base: dev
Choose a base branch
from
38 changes: 38 additions & 0 deletions src/components/ha-date-range-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@ import "@material/mwc-list/mwc-list-item";
import { mdiCalendar } from "@mdi/js";
import {
addDays,
subMinutes,
subHours,
endOfMinute,
endOfHour,
endOfDay,
endOfMonth,
endOfWeek,
endOfYear,
startOfMinute,
startOfHour,
startOfDay,
startOfMonth,
startOfWeek,
Expand Down Expand Up @@ -102,6 +108,38 @@ export class HaDateRangePicker extends LitElement {
);

this._ranges = {
[this.hass.localize(
"ui.components.date-range-picker.ranges.last_30_minutes"
)]: [
calcDate(
subMinutes(today, 30),
startOfMinute,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
),
calcDate(today, endOfMinute, this.hass.locale, this.hass.config, {
weekStartsOn,
}),
],
[this.hass.localize(
"ui.components.date-range-picker.ranges.last_2_hours"
)]: [
calcDate(
subHours(today, 2),
startOfHour,
this.hass.locale,
this.hass.config,
{
weekStartsOn,
}
),
calcDate(today, endOfHour, this.hass.locale, this.hass.config, {
weekStartsOn,
}),
],
[this.hass.localize("ui.components.date-range-picker.ranges.today")]: [
calcDate(today, startOfDay, this.hass.locale, this.hass.config, {
weekStartsOn,
Expand Down
2 changes: 2 additions & 0 deletions src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,8 @@
"select": "Select",
"select_date_range": "Select time period",
"ranges": {
"last_30_minutes": "Last 30 minutes",
"last_2_hours": "Last 2 hours",
"today": "Today",
"yesterday": "Yesterday",
"this_week": "This week",
Expand Down
Loading