FA-6561 / Calendar arithmetic / Open access
Last weekday of month · case 01
Month end is returned without aligning its weekday.
ROOT CAUSE
Month end is returned without aligning its weekday.
THE FAILURE
Month end is returned without aligning its weekday.
Unsuccessful approach: Absolute weekday difference moves by the wrong amount across the week boundary.
Case contract
Valid ISO Gregorian dates in years 1 through 9999; generated dates must remain in that range. Month is 1 through 12 and zero-based weekday is Monday 0 through Sunday 6 unless the output convention says otherwise. Last weekday of month. Exact operational definition: (date(year,month,calendar.monthrange(year,month)[1])-timedelta(days=(date(year,month,calendar.monthrange(year,month)[1]).weekday()-weekday)%7)).isoformat()
Why this case matters
Small exact fixtures expose this error without platform timing, external services, or probabilistic observations. Calendar conventions results depend on the stated convention.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(year, month, weekday):
return date(year,month,calendar.monthrange(year,month)[1]).isoformat()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2024, 2, 0)', solve(*(2024, 2, 0)), '2024-02-26')
check('fixture 2: (2024, 3, 4)', solve(*(2024, 3, 4)), '2024-03-29')
check('fixture 3: (2024, 4, 4)', solve(*(2024, 4, 4)), '2024-04-26')
check('fixture 4: (2024, 2, 3)', solve(*(2024, 2, 3)), '2024-02-29')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: (2024, 2, 0) | 2024-02-29 | 2024-02-26 | Failed |
| fixture 2: (2024, 3, 4) | 2024-03-31 | 2024-03-29 | Failed |
| fixture 3: (2024, 4, 4) | 2024-04-30 | 2024-04-26 | Failed |
| fixture 4: (2024, 2, 3) | 2024-02-29 | 2024-02-29 | Passed |
SHA-256 / 166473d1699d550a4a37cd0c0898c4549d9387a4a7b7c680f39f75987051865a
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
import calendar
import statistics
import itertools
from fractions import Fraction
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal, ROUND_HALF_UP, ROUND_DOWN, ROUND_CEILING, ROUND_FLOOR
N = 1
observations = []
def solve(year, month, weekday):
return (date(year,month,calendar.monthrange(year,month)[1])-timedelta(days=abs(date(year,month,calendar.monthrange(year,month)[1]).weekday()-weekday))).isoformat()
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('fixture 1: (2024, 2, 0)', solve(*(2024, 2, 0)), '2024-02-26')
check('fixture 2: (2024, 3, 4)', solve(*(2024, 3, 4)), '2024-03-29')
check('fixture 3: (2024, 4, 4)', solve(*(2024, 4, 4)), '2024-04-26')
check('fixture 4: (2024, 2, 3)', solve(*(2024, 2, 3)), '2024-02-29')
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| fixture 1: (2024, 2, 0) | 2024-02-26 | 2024-02-26 | Passed |
| fixture 2: (2024, 3, 4) | 2024-03-29 | 2024-03-29 | Passed |
| fixture 3: (2024, 4, 4) | 2024-04-27 | 2024-04-26 | Failed |
| fixture 4: (2024, 2, 3) | 2024-02-29 | 2024-02-29 | Passed |
SHA-256 / 1bd9cb074c01a3afdc6dadcbdb520e623898d144722d7589212575c8cfc2c543
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 4 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:38:03.124070+00:00.
Case digest / 05ab49c39103f2e170e11a4d226a9bc272911d7c1c2796a4726cbb5ed9d7ea03