Fix recurrence rule expansion with ordered weekday
When the order of a weekday in BYDAY rule expansion (like -5SA or 5SU for monthly or 55WE for yearly) exceeds the number of available weekdays in the period (month or year), rule expansion with negative order could result in a floating point exception. The reason: the modified frequency might become zero. Solution. Check order against number of available weekdays and terminate expansion early whenever possible (also for positive orders). Signed-off-by: Lars Henriksen <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
committed by
Lukas Fleischer
parent
fabacecd16
commit
bd238bfd7c
@@ -25,3 +25,4 @@
|
||||
12/25/1997 [1] {3Y w-11} Last Thursday of the year every third year, forever (FREQ=YEARLY;INTERVAL=3;BYDAY=-1TH)
|
||||
06/22/1997 [1] {2Y w0 w1} Every Sunday and Monday, every other year (FREQ=YEARLY;INTERVAL=2;BYDAY=SU,MO)
|
||||
02/01/1997 [1] {1Y -> 01/31/2005 d1 d29 m2} Every year on February 1 and 29 for eight years (RRULE:FREQ=YEARLY;UNTIL=20050131T000000Z;BYMONTH=2;BYMONTHDAY=1,29)
|
||||
08/01/2020 @ 08:41 -> 08/01/2020 @ 10:11 {1M w-41} |negative ordered weekday may not exist
|
||||
|
||||
@@ -6,6 +6,13 @@
|
||||
if [ "$1" = 'actual' ]; then
|
||||
"$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/rfc5545" \
|
||||
-Q --from 1/1/1996 --to 12/31/2007 --filter-type recur
|
||||
echo ""
|
||||
echo "Floating point exception?"
|
||||
"$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/rfc5545" \
|
||||
-Q --day 8/1/2020 --filter-type recur &&
|
||||
"$CALCURSE" --read-only -D "$DATA_DIR"/ -c "$DATA_DIR/rfc5545" \
|
||||
-Q --day 11/1/2020 --filter-type recur &&
|
||||
echo "No Floating point exception on November 1, 2020"
|
||||
elif [ "$1" = 'expected' ]; then
|
||||
cat <<EOD
|
||||
11/05/96:
|
||||
@@ -5323,6 +5330,12 @@ elif [ "$1" = 'expected' ]; then
|
||||
|
||||
12/31/07:
|
||||
* Every Sunday and Monday, every other year (FREQ=YEARLY;INTERVAL=2;BYDAY=SU,MO)
|
||||
|
||||
Floating point exception?
|
||||
08/01/20:
|
||||
- 08:41 -> 10:11
|
||||
negative ordered weekday may not exist
|
||||
No Floating point exception on November 1, 2020
|
||||
EOD
|
||||
else
|
||||
./run-test "$0"
|
||||
|
||||
Reference in New Issue
Block a user