petropavel13 / pg_rrule

RRULE data type for PostgreSQL
MIT License
161 stars 29 forks source link

Did not included start date Sunday on 2021-08-01 with get_occurrences function #16

Closed phuongtran-rent closed 3 years ago

phuongtran-rent commented 3 years ago

Please help me to explain what i am wrong case 1: SELECT * FROM unnest( get_occurrences('FREQ=WEEKLY;INTERVAL=1;BYDAY=SU,MO,TU,WE,TH,FR,SA;UNTIL=20210930T110000Z'::rrule, '2021-07-31 02:00:00'::timestamp) ); Show data: "2021-07-31 02:00:00" "2021-08-01 02:00:00" "2021-08-02 02:00:00" "2021-08-03 02:00:00" ...... "2021-09-30 02:00:00"

wrong case 2: It did not include 2021-08-01 02:00:00 SELECT * FROM unnest( get_occurrences('FREQ=WEEKLY;INTERVAL=1;BYDAY=SU,MO,TU,WE,TH,FR,SA;UNTIL=20210930T110000Z'::rrule, '2021-08-01 02:00:00'::timestamp) ); Show data: "2021-08-02 02:00:00" "2021-08-03 02:00:00" "2021-08-04 02:00:00" .... "2021-09-30 02:00:00"

Case 2 did not include date on 2021-08-01 02:00:00, Please help me to correct it

Thanks

phuongtran-rent commented 3 years ago

I knew rootcase: problem on WKST=SU or WKST=MO Default WKST=MO or WKST=MO if start date is SUN get_occurrences will not include on SUNday

phuongtran-rent commented 3 years ago

WKST=SU will include date sunday as above case SELECT * FROM unnest( get_occurrences('FREQ=WEEKLY;INTERVAL=1;WKST=SU;BYDAY=SU,MO,TU,WE,TH,FR,SA;UNTIL=20210930T110000Z'::rrule, '2021-08-01 02:00:00'::timestamp) ); WKST=MO will not include date sunday as above case SELECT * FROM unnest( get_occurrences('FREQ=WEEKLY;INTERVAL=1;WKST=MO;BYDAY=SU,MO,TU,WE,TH,FR,SA;UNTIL=20210930T110000Z'::rrule, '2021-08-01 02:00:00'::timestamp) );

phuongtran-rent commented 3 years ago

Fond rootcause isssue