Skip to content

More forgiving DTSTART behavior when using only date for UNTIL #128

@grimmdude

Description

@grimmdude

First, thank you for your work on this library 🙏

When UNTIL is defined simply as a date, like 20230331, and you pass a UTC datetime to the second argument of the RRULE constructor you get the following error:

new RRule('RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20230331;INTERVAL=2;BYDAY=TH', date_create());

Invalid UNTIL property: if the "DTSTART" property is specified as a date with UTC time or a date with local time and time zone reference, then the UNTIL rule part MUST be specified as a date with UTC time.

I understand if this technically abides by the RFC spec, however internally the library seems to cast the value of UNTIL into a UTC datetime anyway.

> $rrule = (new RRule('RRULE:FREQ=WEEKLY;WKST=SU;UNTIL=20230331;INTERVAL=2;BYDAY=TH'))->getRule()
= [
    "DTSTART" => null,
    "FREQ" => "WEEKLY",
    "UNTIL" => DateTime @1680220800 {#3854
      date: 2023-03-31 00:00:00.0 UTC (+00:00),
    },
    "COUNT" => null,
    "INTERVAL" => "2",
    "BYSECOND" => null,
    "BYMINUTE" => null,
    "BYHOUR" => null,
    "BYDAY" => "TH",
    "BYMONTHDAY" => null,
    "BYYEARDAY" => null,
    "BYWEEKNO" => null,
    "BYMONTH" => null,
    "BYSETPOS" => null,
    "WKST" => "SU",
  ]

Would it be acceptable for the library to be a little more forgiving in this case and allow a UTC datetime to be used as the value for DTSTART?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions