Fix All Day recurring events that end on a specific date (#14905)

This commit is contained in:
Allen Porter 2022-12-30 04:15:07 -08:00 committed by GitHub
parent a16e41a7ac
commit 4901d50918
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -250,6 +250,7 @@ class DialogCalendarEventEditor extends LitElement {
<ha-recurrence-rule-editor
.hass=${this.hass}
.dtstart=${this._dtstart}
.allDay=${this._allDay}
.locale=${this.hass.locale}
.timezone=${this.hass.config.time_zone}
.value=${this._rrule || ""}

View File

@ -41,6 +41,8 @@ export class RecurrenceRuleEditor extends LitElement {
@property() public dtstart?: Date;
@property() public allDay?: boolean;
@property({ attribute: false }) public locale!: HomeAssistant["locale"];
@property() public timezone?: string;
@ -402,7 +404,14 @@ export class RecurrenceRuleEditor extends LitElement {
byweekday: byweekday,
bymonthday: bymonthday,
};
const contentline = RRule.optionsToString(options);
let contentline = RRule.optionsToString(options);
if (this._until && this.allDay) {
// rrule.js only computes UNTIL values as DATE-TIME however rfc5545 says
// The value of the UNTIL rule part MUST have the same value type as the
// "DTSTART" property. If needed, strip off any time values as a workaround
// This converts "UNTIL=20220512T060000" to "UNTIL=20220512"
contentline = contentline.replace(/(UNTIL=\d{8})T\d{6}Z?/, "$1");
}
return contentline.slice(6); // Strip "RRULE:" prefix
}