rlanvin / php-rrule

Lightweight and fast recurring dates library for PHP (RFC 5545)
Other
603 stars 83 forks source link

Weekly WKST Parameter issue #114

Closed arsys closed 2 years ago

arsys commented 2 years ago

Weekly start parameter not working. $weekly = new RRule([ 'FREQ' => 'WEEKLY', 'INTERVAL' => 2, 'DTSTART' => '2022-09-15', 'COUNT' => 2, 'WKST' => 'MO' ]);

Result: 2022-09-15 Thursday, 2022-09-29 Thursday

rlanvin commented 2 years ago

This looks normal, what result are you expecting?

arsys commented 2 years ago

I though if use WKST = MO parameter then result will be : 2022-09-19 Monday, 2022-09-26 Monday

pluk77 commented 2 years ago

According to the documentation, WKST sets the start-date of the week, but does not set the start date of your weekly recurring events. If you want your events to only be on a Monday, you can use BYDAY, or WEEKLY and make sure the first DTSTART is on a Monday. Using BYDAY is probably easier.

WKST: The week start day. Must be one of the following strings MO, TU, WE, TH, FR, SA, SU. This will affect recurrences based on weekly periods. Default is MO (Monday).

BYWEEKNO: The week number(s) to apply the recurrence to, from 1 to 53 or -53 to -1. Negative values mean that the counting start from the end of the year, so -1 means "the last week of the year". Week numbers have the meaning described in ISO8601, that is, the first week of the year is that containing at least four days of the new year. Week numbers are affected by the WKST setting.

arsys commented 2 years ago

I got it Thank you.

$weekly = new RRule([ 'FREQ' => 'WEEKLY', 'INTERVAL' => 2, 'DTSTART' => '2022-09-15', 'COUNT' => 10, 'BYDAY' => 'SU' ]);

Result: 2022-09-18 Sunday, 2022-10-02 Sunday, 2022-10-16 Sunday, ... .. .. ..., 2023-01-22 Sunday