{"abstract":"A 5th-Monday series reports the 4th Monday in months without a fifth one.","category":"Calendar recurrence rules","checks":7,"contract":"FREQ=MONTHLY;BYDAY=<ordinal><weekday>. weekday is 0=Monday..6=Sunday; ordinal 1..5 counts from the start of the month and -1..-5 from the end. A month lacking that occurrence is skipped and does not consume COUNT. Months step by interval from the dtstart month; instances before dtstart are dropped. Return the first count ISO dates.","contract_signature":"dtstart, interval, ordinal, weekday, count","evaluation_group":"w2-calendar-recurrence-rules-monthly-nth-weekday","failed_approach":"The partial repair `if day < 1 or day > dim:;     break` stops the whole series at the first month without the occurrence.","family":"w2-calendar-recurrence-rules-monthly-nth-weekday-missing-occurrence","id":"FA-76906","implementations":{"attempt":{"sha256":"0958bc877e75b86c4dc85a1f813c58adec22c8417863af80f67ccd8621c75bda","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport datetime as dt\nimport calendar\nN = 1\nobservations = []\ndef solve(dtstart, interval, ordinal, weekday, count):\n    start = dt.date.fromisoformat(dtstart)\n    out = []\n    for k in range(600):\n        if len(out) >= count:\n            return out\n        mi = start.month - 1 + k * interval\n        y, m = start.year + mi // 12, mi % 12 + 1\n        dim = calendar.monthrange(y, m)[1]\n        first_wd = dt.date(y, m, 1).weekday()\n        last_wd = dt.date(y, m, dim).weekday()\n        if ordinal > 0:\n            day = 1 + (weekday - first_wd) % 7 + 7 * (ordinal - 1)\n        else:\n            day = dim - (last_wd - weekday) % 7 + 7 * (ordinal + 1)\n        if day < 1 or day > dim:\n            break\n        d = dt.date(y, m, day)\n        if d < start:\n            continue\n        out.append(d.isoformat())\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: second tuesday',\n   ['2024-01-01', 1, 2, 1, 4],\n   ['2024-01-09', '2024-02-13', '2024-03-12', '2024-04-09']),\n  ('last friday', ['2024-01-01', 1, -1, 4, 4], ['2024-01-26', '2024-02-23', '2024-03-29', '2024-04-26']),\n  ('second to last sunday',\n   ['2024-02-01', 1, -2, 6, 4],\n   ['2024-02-18', '2024-03-24', '2024-04-21', '2024-05-19']),\n  ('fifth monday skips months', ['2024-01-01', 1, 5, 0, 3], ['2024-01-29', '2024-04-29', '2024-07-29']),\n  ('interval 2 first saturday',\n   ['2024-11-01', 2, 1, 5, 4],\n   ['2024-11-02', '2025-01-04', '2025-03-01', '2025-05-03']),\n  ('first-month occurrence before dtstart',\n   ['2024-03-20', 1, 1, 2, 3],\n   ['2024-04-03', '2024-05-01', '2024-06-05']),\n  ('third wednesday quarterly',\n   ['2023-12-01', 3, 3, 2, 4],\n   ['2023-12-20', '2024-03-20', '2024-06-19', '2024-09-18'])],\n [('second to last sunday',\n   ['2024-02-01', 1, -2, 6, 4],\n   ['2024-02-18', '2024-03-24', '2024-04-21', '2024-05-19']),\n  ('fifth monday skips months', ['2024-01-01', 1, 5, 0, 3], ['2024-01-29', '2024-04-29', '2024-07-29']),\n  ('interval 2 first saturday',\n   ['2024-11-01', 2, 1, 5, 4],\n   ['2024-11-02', '2025-01-04', '2025-03-01', '2025-05-03']),\n  ('first-month occurrence before dtstart',\n   ['2024-03-20', 1, 1, 2, 3],\n   ['2024-04-03', '2024-05-01', '2024-06-05']),\n  ('third wednesday quarterly',\n   ['2023-12-01', 3, 3, 2, 4],\n   ['2023-12-20', '2024-03-20', '2024-06-19', '2024-09-18']),\n  ('fourth sunday', ['2025-02-10', 1, 4, 6, 4], ['2025-02-23', '2025-03-23', '2025-04-27', '2025-05-25']),\n  ('last monday dtstart on it', ['2024-05-27', 1, -1, 0, 3], ['2024-05-27', '2024-06-24', '2024-07-29'])],\n [('interval 2 first saturday',\n   ['2024-11-01', 2, 1, 5, 4],\n   ['2024-11-02', '2025-01-04', '2025-03-01', '2025-05-03']),\n  ('first-month occurrence before dtstart',\n   ['2024-03-20', 1, 1, 2, 3],\n   ['2024-04-03', '2024-05-01', '2024-06-05']),\n  ('third wednesday quarterly',\n   ['2023-12-01', 3, 3, 2, 4],\n   ['2023-12-20', '2024-03-20', '2024-06-19', '2024-09-18']),\n  ('fourth sunday', ['2025-02-10', 1, 4, 6, 4], ['2025-02-23', '2025-03-23', '2025-04-27', '2025-05-25']),\n  ('last monday dtstart on it', ['2024-05-27', 1, -1, 0, 3], ['2024-05-27', '2024-06-24', '2024-07-29']),\n  ('count zero', ['2024-01-01', 1, 1, 0, 0], []),\n  ('fifth friday interval 1',\n   ['2024-02-01', 1, 5, 4, 4],\n   ['2024-03-29', '2024-05-31', '2024-08-30', '2024-11-29'])],\n [('third wednesday quarterly',\n   ['2023-12-01', 3, 3, 2, 4],\n   ['2023-12-20', '2024-03-20', '2024-06-19', '2024-09-18']),\n  ('fourth sunday', ['2025-02-10', 1, 4, 6, 4], ['2025-02-23', '2025-03-23', '2025-04-27', '2025-05-25']),\n  ('last monday dtstart on it', ['2024-05-27', 1, -1, 0, 3], ['2024-05-27', '2024-06-24', '2024-07-29']),\n  ('count zero', ['2024-01-01', 1, 1, 0, 0], []),\n  ('fifth friday interval 1',\n   ['2024-02-01', 1, 5, 4, 4],\n   ['2024-03-29', '2024-05-31', '2024-08-30', '2024-11-29']),\n  ('regression: second tuesday',\n   ['2024-01-01', 1, 2, 1, 4],\n   ['2024-01-09', '2024-02-13', '2024-03-12', '2024-04-09']),\n  ('last friday', ['2024-01-01', 1, -1, 4, 4], ['2024-01-26', '2024-02-23', '2024-03-29', '2024-04-26'])],\n [('last monday dtstart on it', ['2024-05-27', 1, -1, 0, 3], ['2024-05-27', '2024-06-24', '2024-07-29']),\n  ('count zero', ['2024-01-01', 1, 1, 0, 0], []),\n  ('fifth friday interval 1',\n   ['2024-02-01', 1, 5, 4, 4],\n   ['2024-03-29', '2024-05-31', '2024-08-30', '2024-11-29']),\n  ('regression: second tuesday',\n   ['2024-01-01', 1, 2, 1, 4],\n   ['2024-01-09', '2024-02-13', '2024-03-12', '2024-04-09']),\n  ('last friday', ['2024-01-01', 1, -1, 4, 4], ['2024-01-26', '2024-02-23', '2024-03-29', '2024-04-26']),\n  ('second to last sunday',\n   ['2024-02-01', 1, -2, 6, 4],\n   ['2024-02-18', '2024-03-24', '2024-04-21', '2024-05-19']),\n  ('fifth monday skips months', ['2024-01-01', 1, 5, 0, 3], ['2024-01-29', '2024-04-29', '2024-07-29'])]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"2754b130bc9693cdecf4a686ed7ebd78b0c1f65d9f2cbd4bac74c2ae7a8699b8","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\nimport datetime as dt\nimport calendar\nN = 1\nobservations = []\ndef solve(dtstart, interval, ordinal, weekday, count):\n    start = dt.date.fromisoformat(dtstart)\n    out = []\n    for k in range(600):\n        if len(out) >= count:\n            return out\n        mi = start.month - 1 + k * interval\n        y, m = start.year + mi // 12, mi % 12 + 1\n        dim = calendar.monthrange(y, m)[1]\n        first_wd = dt.date(y, m, 1).weekday()\n        last_wd = dt.date(y, m, dim).weekday()\n        if ordinal > 0:\n            day = 1 + (weekday - first_wd) % 7 + 7 * (ordinal - 1)\n        else:\n            day = dim - (last_wd - weekday) % 7 + 7 * (ordinal + 1)\n        if day > dim:\n            day -= 7\n        d = dt.date(y, m, day)\n        if d < start:\n            continue\n        out.append(d.isoformat())\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('regression: second tuesday',\n   ['2024-01-01', 1, 2, 1, 4],\n   ['2024-01-09', '2024-02-13', '2024-03-12', '2024-04-09']),\n  ('last friday', ['2024-01-01', 1, -1, 4, 4], ['2024-01-26', '2024-02-23', '2024-03-29', '2024-04-26']),\n  ('second to last sunday',\n   ['2024-02-01', 1, -2, 6, 4],\n   ['2024-02-18', '2024-03-24', '2024-04-21', '2024-05-19']),\n  ('fifth monday skips months', ['2024-01-01', 1, 5, 0, 3], ['2024-01-29', '2024-04-29', '2024-07-29']),\n  ('interval 2 first saturday',\n   ['2024-11-01', 2, 1, 5, 4],\n   ['2024-11-02', '2025-01-04', '2025-03-01', '2025-05-03']),\n  ('first-month occurrence before dtstart',\n   ['2024-03-20', 1, 1, 2, 3],\n   ['2024-04-03', '2024-05-01', '2024-06-05']),\n  ('third wednesday quarterly',\n   ['2023-12-01', 3, 3, 2, 4],\n   ['2023-12-20', '2024-03-20', '2024-06-19', '2024-09-18'])],\n [('second to last sunday',\n   ['2024-02-01', 1, -2, 6, 4],\n   ['2024-02-18', '2024-03-24', '2024-04-21', '2024-05-19']),\n  ('fifth monday skips months', ['2024-01-01', 1, 5, 0, 3], ['2024-01-29', '2024-04-29', '2024-07-29']),\n  ('interval 2 first saturday',\n   ['2024-11-01', 2, 1, 5, 4],\n   ['2024-11-02', '2025-01-04', '2025-03-01', '2025-05-03']),\n  ('first-month occurrence before dtstart',\n   ['2024-03-20', 1, 1, 2, 3],\n   ['2024-04-03', '2024-05-01', '2024-06-05']),\n  ('third wednesday quarterly',\n   ['2023-12-01', 3, 3, 2, 4],\n   ['2023-12-20', '2024-03-20', '2024-06-19', '2024-09-18']),\n  ('fourth sunday', ['2025-02-10', 1, 4, 6, 4], ['2025-02-23', '2025-03-23', '2025-04-27', '2025-05-25']),\n  ('last monday dtstart on it', ['2024-05-27', 1, -1, 0, 3], ['2024-05-27', '2024-06-24', '2024-07-29'])],\n [('interval 2 first saturday',\n   ['2024-11-01', 2, 1, 5, 4],\n   ['2024-11-02', '2025-01-04', '2025-03-01', '2025-05-03']),\n  ('first-month occurrence before dtstart',\n   ['2024-03-20', 1, 1, 2, 3],\n   ['2024-04-03', '2024-05-01', '2024-06-05']),\n  ('third wednesday quarterly',\n   ['2023-12-01', 3, 3, 2, 4],\n   ['2023-12-20', '2024-03-20', '2024-06-19', '2024-09-18']),\n  ('fourth sunday', ['2025-02-10', 1, 4, 6, 4], ['2025-02-23', '2025-03-23', '2025-04-27', '2025-05-25']),\n  ('last monday dtstart on it', ['2024-05-27', 1, -1, 0, 3], ['2024-05-27', '2024-06-24', '2024-07-29']),\n  ('count zero', ['2024-01-01', 1, 1, 0, 0], []),\n  ('fifth friday interval 1',\n   ['2024-02-01', 1, 5, 4, 4],\n   ['2024-03-29', '2024-05-31', '2024-08-30', '2024-11-29'])],\n [('third wednesday quarterly',\n   ['2023-12-01', 3, 3, 2, 4],\n   ['2023-12-20', '2024-03-20', '2024-06-19', '2024-09-18']),\n  ('fourth sunday', ['2025-02-10', 1, 4, 6, 4], ['2025-02-23', '2025-03-23', '2025-04-27', '2025-05-25']),\n  ('last monday dtstart on it', ['2024-05-27', 1, -1, 0, 3], ['2024-05-27', '2024-06-24', '2024-07-29']),\n  ('count zero', ['2024-01-01', 1, 1, 0, 0], []),\n  ('fifth friday interval 1',\n   ['2024-02-01', 1, 5, 4, 4],\n   ['2024-03-29', '2024-05-31', '2024-08-30', '2024-11-29']),\n  ('regression: second tuesday',\n   ['2024-01-01', 1, 2, 1, 4],\n   ['2024-01-09', '2024-02-13', '2024-03-12', '2024-04-09']),\n  ('last friday', ['2024-01-01', 1, -1, 4, 4], ['2024-01-26', '2024-02-23', '2024-03-29', '2024-04-26'])],\n [('last monday dtstart on it', ['2024-05-27', 1, -1, 0, 3], ['2024-05-27', '2024-06-24', '2024-07-29']),\n  ('count zero', ['2024-01-01', 1, 1, 0, 0], []),\n  ('fifth friday interval 1',\n   ['2024-02-01', 1, 5, 4, 4],\n   ['2024-03-29', '2024-05-31', '2024-08-30', '2024-11-29']),\n  ('regression: second tuesday',\n   ['2024-01-01', 1, 2, 1, 4],\n   ['2024-01-09', '2024-02-13', '2024-03-12', '2024-04-09']),\n  ('last friday', ['2024-01-01', 1, -1, 4, 4], ['2024-01-26', '2024-02-23', '2024-03-29', '2024-04-26']),\n  ('second to last sunday',\n   ['2024-02-01', 1, -2, 6, 4],\n   ['2024-02-18', '2024-03-24', '2024-04-21', '2024-05-19']),\n  ('fifth monday skips months', ['2024-01-01', 1, 5, 0, 3], ['2024-01-29', '2024-04-29', '2024-07-29'])]]\nfor label, args, expected in fixtures[N-1]:\n    check(label, solve(*args), expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"Stipulated, bounded recurrence-expansion model evaluated offline on explicit fixtures; it is not a complete iCalendar implementation and makes no claim of standards conformance. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-calendar-recurrence-rules-monthly-nth-weekday-missing-occurrence","generated_at":"2026-09-29T14:49:20.576312+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Recurring calendar series are expanded into concrete instances for display, reminders and conflict checks.","root_cause":"A nonexistent fifth occurrence falls back to the previous week instead of skipping the month.","sha256":"bca335ad0d6866e115fbf38097f2f2d60df5463c2663f163080022fd48af7554","title":"Monthly ordinal BYDAY such as 2TU or -1FR: missing occurrence · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":45.651,"exit_code":1,"observations":[{"actual":["2024-01-09","2024-02-13","2024-03-12","2024-04-09"],"check":"regression: second tuesday","expected":["2024-01-09","2024-02-13","2024-03-12","2024-04-09"],"passed":true},{"actual":["2024-01-26","2024-02-23","2024-03-29","2024-04-26"],"check":"last friday","expected":["2024-01-26","2024-02-23","2024-03-29","2024-04-26"],"passed":true},{"actual":["2024-02-18","2024-03-24","2024-04-21","2024-05-19"],"check":"second to last sunday","expected":["2024-02-18","2024-03-24","2024-04-21","2024-05-19"],"passed":true},{"actual":["2024-01-29"],"check":"fifth monday skips months","expected":["2024-01-29","2024-04-29","2024-07-29"],"passed":false},{"actual":["2024-11-02","2025-01-04","2025-03-01","2025-05-03"],"check":"interval 2 first saturday","expected":["2024-11-02","2025-01-04","2025-03-01","2025-05-03"],"passed":true},{"actual":["2024-04-03","2024-05-01","2024-06-05"],"check":"first-month occurrence before dtstart","expected":["2024-04-03","2024-05-01","2024-06-05"],"passed":true},{"actual":["2023-12-20","2024-03-20","2024-06-19","2024-09-18"],"check":"third wednesday quarterly","expected":["2023-12-20","2024-03-20","2024-06-19","2024-09-18"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: second tuesday\", \"actual\": [\"2024-01-09\", \"2024-02-13\", \"2024-03-12\", \"2024-04-09\"], \"expected\": [\"2024-01-09\", \"2024-02-13\", \"2024-03-12\", \"2024-04-09\"], \"passed\": true}, {\"check\": \"last friday\", \"actual\": [\"2024-01-26\", \"2024-02-23\", \"2024-03-29\", \"2024-04-26\"], \"expected\": [\"2024-01-26\", \"2024-02-23\", \"2024-03-29\", \"2024-04-26\"], \"passed\": true}, {\"check\": \"second to last sunday\", \"actual\": [\"2024-02-18\", \"2024-03-24\", \"2024-04-21\", \"2024-05-19\"], \"expected\": [\"2024-02-18\", \"2024-03-24\", \"2024-04-21\", \"2024-05-19\"], \"passed\": true}, {\"check\": \"fifth monday skips months\", \"actual\": [\"2024-01-29\"], \"expected\": [\"2024-01-29\", \"2024-04-29\", \"2024-07-29\"], \"passed\": false}, {\"check\": \"interval 2 first saturday\", \"actual\": [\"2024-11-02\", \"2025-01-04\", \"2025-03-01\", \"2025-05-03\"], \"expected\": [\"2024-11-02\", \"2025-01-04\", \"2025-03-01\", \"2025-05-03\"], \"passed\": true}, {\"check\": \"first-month occurrence before dtstart\", \"actual\": [\"2024-04-03\", \"2024-05-01\", \"2024-06-05\"], \"expected\": [\"2024-04-03\", \"2024-05-01\", \"2024-06-05\"], \"passed\": true}, {\"check\": \"third wednesday quarterly\", \"actual\": [\"2023-12-20\", \"2024-03-20\", \"2024-06-19\", \"2024-09-18\"], \"expected\": [\"2023-12-20\", \"2024-03-20\", \"2024-06-19\", \"2024-09-18\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":43.204,"exit_code":1,"observations":[{"actual":["2024-01-09","2024-02-13","2024-03-12","2024-04-09"],"check":"regression: second tuesday","expected":["2024-01-09","2024-02-13","2024-03-12","2024-04-09"],"passed":true},{"actual":["2024-01-26","2024-02-23","2024-03-29","2024-04-26"],"check":"last friday","expected":["2024-01-26","2024-02-23","2024-03-29","2024-04-26"],"passed":true},{"actual":["2024-02-18","2024-03-24","2024-04-21","2024-05-19"],"check":"second to last sunday","expected":["2024-02-18","2024-03-24","2024-04-21","2024-05-19"],"passed":true},{"actual":["2024-01-29","2024-02-26","2024-03-25"],"check":"fifth monday skips months","expected":["2024-01-29","2024-04-29","2024-07-29"],"passed":false},{"actual":["2024-11-02","2025-01-04","2025-03-01","2025-05-03"],"check":"interval 2 first saturday","expected":["2024-11-02","2025-01-04","2025-03-01","2025-05-03"],"passed":true},{"actual":["2024-04-03","2024-05-01","2024-06-05"],"check":"first-month occurrence before dtstart","expected":["2024-04-03","2024-05-01","2024-06-05"],"passed":true},{"actual":["2023-12-20","2024-03-20","2024-06-19","2024-09-18"],"check":"third wednesday quarterly","expected":["2023-12-20","2024-03-20","2024-06-19","2024-09-18"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"regression: second tuesday\", \"actual\": [\"2024-01-09\", \"2024-02-13\", \"2024-03-12\", \"2024-04-09\"], \"expected\": [\"2024-01-09\", \"2024-02-13\", \"2024-03-12\", \"2024-04-09\"], \"passed\": true}, {\"check\": \"last friday\", \"actual\": [\"2024-01-26\", \"2024-02-23\", \"2024-03-29\", \"2024-04-26\"], \"expected\": [\"2024-01-26\", \"2024-02-23\", \"2024-03-29\", \"2024-04-26\"], \"passed\": true}, {\"check\": \"second to last sunday\", \"actual\": [\"2024-02-18\", \"2024-03-24\", \"2024-04-21\", \"2024-05-19\"], \"expected\": [\"2024-02-18\", \"2024-03-24\", \"2024-04-21\", \"2024-05-19\"], \"passed\": true}, {\"check\": \"fifth monday skips months\", \"actual\": [\"2024-01-29\", \"2024-02-26\", \"2024-03-25\"], \"expected\": [\"2024-01-29\", \"2024-04-29\", \"2024-07-29\"], \"passed\": false}, {\"check\": \"interval 2 first saturday\", \"actual\": [\"2024-11-02\", \"2025-01-04\", \"2025-03-01\", \"2025-05-03\"], \"expected\": [\"2024-11-02\", \"2025-01-04\", \"2025-03-01\", \"2025-05-03\"], \"passed\": true}, {\"check\": \"first-month occurrence before dtstart\", \"actual\": [\"2024-04-03\", \"2024-05-01\", \"2024-06-05\"], \"expected\": [\"2024-04-03\", \"2024-05-01\", \"2024-06-05\"], \"passed\": true}, {\"check\": \"third wednesday quarterly\", \"actual\": [\"2023-12-20\", \"2024-03-20\", \"2024-06-19\", \"2024-09-18\"], \"expected\": [\"2023-12-20\", \"2024-03-20\", \"2024-06-19\", \"2024-09-18\"], \"passed\": true}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}