diff --git a/CHANGELOG.md b/CHANGELOG.md index bb56c729..eb27a499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Improve Grafana Alerting integration by @Ferril @teodosii ([#2742](https://github.com/grafana/oncall/pull/2742)) +- Fixed UTC conversion for escalation chain step of timerange + ([#2781](https://github.com/grafana/oncall/issues/2781)) ## v1.3.24 (2023-08-17) diff --git a/engine/apps/alerts/models/escalation_policy.py b/engine/apps/alerts/models/escalation_policy.py index a55f1d1b..1ae8da43 100644 --- a/engine/apps/alerts/models/escalation_policy.py +++ b/engine/apps/alerts/models/escalation_policy.py @@ -129,7 +129,7 @@ class EscalationPolicy(OrderedModel): STEP_TRIGGER_CUSTOM_WEBHOOK: ("Trigger webhook {{custom_webhook}}", "Trigger webhook"), STEP_NOTIFY_USERS_QUEUE: ("Round robin notification for {{users}}", "Notify users one by one (round-robin)"), STEP_NOTIFY_IF_TIME: ( - "Continue escalation if current time is in {{timerange}}", + "Continue escalation if current UTC time is in {{timerange}}", "Continue escalation if current time is in range", ), STEP_NOTIFY_IF_NUM_ALERTS_IN_TIME_WINDOW: ( diff --git a/grafana-plugin/src/components/TimeRange/TimeRange.tsx b/grafana-plugin/src/components/TimeRange/TimeRange.tsx index 66bdb00b..b48e7435 100644 --- a/grafana-plugin/src/components/TimeRange/TimeRange.tsx +++ b/grafana-plugin/src/components/TimeRange/TimeRange.tsx @@ -17,8 +17,8 @@ interface TimeRangeProps { } function getMoments(from: string, to: string) { - let fromMoment; - let toMoment; + let fromMoment: moment.Moment; + let toMoment: moment.Moment; if (!from || !to) { fromMoment = moment().startOf('hour'); @@ -29,18 +29,18 @@ function getMoments(from: string, to: string) { } } else { const [fh, fm] = from.split(':').map(Number); - fromMoment = moment().utc().hour(fh).minute(fm).second(0).local(); + fromMoment = moment().hour(fh).minute(fm).second(0).local(); const [th, tm] = to.split(':').map(Number); - toMoment = moment().utc().hour(th).minute(tm).second(0).local(); + toMoment = moment().hour(th).minute(tm).second(0).local(); } return [fromMoment, toMoment]; } function getRangeStrings(from: moment.Moment, to: moment.Moment) { - const fromString = from.clone().utc().format('HH:mm:00'); - const toString = to.clone().utc().format('HH:mm:00'); + const fromString = from.clone().format('HH:mm:00'); + const toString = to.clone().format('HH:mm:00'); return [fromString, toString]; } @@ -48,9 +48,7 @@ function getRangeStrings(from: moment.Moment, to: moment.Moment) { const TimeRange = (props: TimeRangeProps) => { const { className, from: f, to: t, onChange, disabled } = props; - // @ts-ignore const [from, setFrom] = useState(getMoments(f, t)[0]); - // @ts-ignore const [to, setTo] = useState(getMoments(f, t)[1]); useEffect(() => {