@@ -512,7 +512,7 @@ static const char *oxcical_parse_rrule(const ical_component &tzcom,
512512 if (psubval_list->size () == 1 ) {
513513 int wd = 0 , order = 0 ;
514514 if (!ical_parse_byday (psubval_list->begin ()->c_str (), &wd, &order))
515- return " E-2806: Parse error at RRULE.BYDAY" ;
515+ return " E-2806: Parse error at RRULE(MONTHLY) .BYDAY" ;
516516 apr->recur_pat .pts .monthnth .weekrecur |= 1 << wd;
517517 if (order > 4 || order < -1 )
518518 return " E-2831: weekorder out of range for MAPI" ;
@@ -560,6 +560,7 @@ static const char *oxcical_parse_rrule(const ical_component &tzcom,
560560 if (irrule.test_bymask (rrule_by::day) &&
561561 irrule.test_bymask (rrule_by::setpos) &&
562562 irrule.test_bymask (rrule_by::month)) {
563+ /* Both limiters ("BYDAY=TU; BYSETPOS=4") */
563564 if (irrule.test_bymask (rrule_by::monthday))
564565 return " E-2820" ;
565566 patterntype = rptMonthNth;
@@ -578,6 +579,28 @@ static const char *oxcical_parse_rrule(const ical_component &tzcom,
578579 else if (tmp_int == -1 )
579580 tmp_int = 5 ;
580581 apr->recur_pat .pts .monthnth .recurnum = tmp_int;
582+ } else if (irrule.test_bymask (rrule_by::day) &&
583+ !irrule.test_bymask (rrule_by::setpos) &&
584+ irrule.test_bymask (rrule_by::month)) {
585+ /* BYDAY limiter ("BYDAY=4TU") */
586+ if (irrule.test_bymask (rrule_by::monthday))
587+ return " E-2827" ;
588+ patterntype = rptMonthNth;
589+ psubval_list = piline->get_subval_list (" BYDAY" );
590+ apr->recur_pat .pts .monthnth .weekrecur = 0 ;
591+ if (psubval_list->size () > 1 )
592+ return " E-2872: MAPI does not support YEARLY with multiple BYDAY" ;
593+ if (psubval_list->size () == 1 ) {
594+ int wd = 0 , order = 0 ;
595+ if (!ical_parse_byday (psubval_list->begin ()->c_str (), &wd, &order))
596+ return " E-2873: Parse error at RRULE(YEARLY).BYDAY" ;
597+ apr->recur_pat .pts .monthnth .weekrecur |= 1 << wd;
598+ if (order > 4 || order < -1 )
599+ return " E-2874: weekorder out of range for MAPI" ;
600+ else if (order == -1 )
601+ order = 5 ;
602+ apr->recur_pat .pts .monthnth .recurnum = order;
603+ }
581604 } else {
582605 if (irrule.test_bymask (rrule_by::day) ||
583606 irrule.test_bymask (rrule_by::setpos))
0 commit comments