MCPcopy Create free account
hub / github.com/microsoft/AI-Engineering-Coach / fillWeekRange

Function fillWeekRange

src/core/helpers.ts:72–90  ·  view source on GitHub ↗
(weeks: string[])

Source from the content-addressed store, hash-verified

70
71/** Return every ISO week label between the first and last entry in `weeks` (inclusive). */
72export function fillWeekRange(weeks: string[]): string[] {
73 if (weeks.length <= 1) return weeks;
74 const sorted = [...weeks].sort();
75 const toMonday = (label: string): Date => {
76 const [y, w] = label.split('-W').map(Number);
77 const jan4 = new Date(y, 0, 4);
78 const dow = (jan4.getDay() + 6) % 7;
79 const mon = new Date(jan4);
80 mon.setDate(jan4.getDate() - dow + (w - 1) * 7);
81 return mon;
82 };
83 const start = toMonday(sorted[0]);
84 const end = toMonday(sorted[sorted.length - 1]);
85 const result: string[] = [];
86 for (const d = new Date(start); d <= end; d.setDate(d.getDate() + 7)) {
87 result.push(isoWeek(d));
88 }
89 return result;
90}
91
92/** Return every YYYY-MM between the first and last entry in `months` (inclusive). */
93export function fillMonthRange(months: string[]): string[] {

Callers

nothing calls this directly

Calls 2

toMondayFunction · 0.85
isoWeekFunction · 0.85

Tested by

no test coverage detected