Set the decision and its input
The supplied monthly rule requests day31 in February and March2027. Under skip, February has no occurrence and March produces31March. A last-day implementation instead creates28February. Both are possible local policies; only the declared one is accepted here.
| Case | Input JSON |
|---|---|
| Base test | {"year":2027,"months":[2,3],"day":31,"rule":"skip"} |
Run the supplied comparison
The programme uses UTC Gregorian month lengths to expand those original policies. It does not parse an external recurrence format or claim what a provider defaults to.
| Path | Output JSON |
|---|---|
| Faulty path | {"dates":["2027-02-28","2027-03-31"]} |
| Required path | {"dates":[null,"2027-03-31"]} |
import assert from 'node:assert/strict';
const run=function run(i,corrected=true){
if(!['skip','last-day'].includes(i.rule)||!Number.isInteger(i.year)||i.year<100||i.year>9999||!Number.isInteger(i.day)||i.day<1||i.day>31||!i.months.every(m=>Number.isInteger(m)&&m>=1&&m<=12))return {held:true};
const dates=i.months.map(month=>{const last=new Date(Date.UTC(i.year,month,0)).getUTCDate();const day=corrected&&i.rule==='skip'&&i.day>last?null:Math.min(i.day,last);return day===null?null:i.year+'-'+String(month).padStart(2,'0')+'-'+String(day).padStart(2,'0');});
return {dates};
};
const cases=[{"input":{"year":2027,"months":[2,3],"day":31,"rule":"skip"},"corrected":false,"expected":{"dates":["2027-02-28","2027-03-31"]}},{"input":{"year":2027,"months":[2,3],"day":31,"rule":"skip"},"corrected":true,"expected":{"dates":[null,"2027-03-31"]}},{"input":{"year":2028,"months":[2],"day":31,"rule":"last-day"},"corrected":true,"expected":{"dates":["2028-02-29"]}},{"input":{"year":2027,"months":[1],"day":31,"rule":"skip"},"corrected":true,"expected":{"dates":["2027-01-31"]}},{"input":{"year":2027,"months":[2],"day":31,"rule":null},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
The declared2028 leap-year last-day boundary yields29February. January31 exists under skip. An absent policy is held.
- Read the absent-day policy
- Expand actual month lengths
- Record generated or absent occurrences
Do not substitute month-end without an explicit rule.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| declared leap-year last day | {"year":2028,"months":[2],"day":31,"rule":"last-day"} | {"dates":["2028-02-29"]} |
| valid thirty-first day | {"year":2027,"months":[1],"day":31,"rule":"skip"} | {"dates":["2027-01-31"]} |
| occurrence rule missing | {"year":2027,"months":[2],"day":31,"rule":null} | {"held":true} |
Is the base February skip occurrence a failed job?
Show the worked answer
No. No February occurrence is generated under the supplied rule. Do not reconcile it as an expected but missing run.