Skip to content

Commit

Permalink
Include last 30 min and 2 hours
Browse files Browse the repository at this point in the history
  • Loading branch information
tasomaniac authored Jan 22, 2025
1 parent b89bd0b commit 520e555
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/components/ha-date-range-picker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,18 @@ import type { ActionDetail } from "@material/mwc-list/mwc-list-foundation";
import "@material/mwc-list/mwc-list-item";
import { mdiCalendar } from "@mdi/js";
import {
addHours,

Check failure on line 7 in src/components/ha-date-range-picker.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

'addHours' is defined but never used. Allowed unused vars must match /^_/u

Check failure on line 7 in src/components/ha-date-range-picker.ts

View workflow job for this annotation

GitHub Actions / Lint and check format

'addHours' is defined but never used
addDays,
subMinutes,
subHours,
endOfMinute,
endOfHour,
endOfDay,
endOfMonth,
endOfWeek,
endOfYear,
startOfMinute,
startOfHour,
startOfDay,
startOfMonth,
startOfWeek,
Expand Down Expand Up @@ -102,6 +109,46 @@ export class HaDateRangePicker extends LitElement {
);

this._ranges = {
[this.hass.localize("ui.components.date-range-picker.ranges.last_30_min")]: [
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

0 comments on commit 520e555

Please sign in to comment.