MCPcopy Create free account
hub / github.com/Thanas-R/Virdis / parseMonthRange

Function parseMonthRange

src/components/CropPlanningSection.tsx:1090–1105  ·  view source on GitHub ↗
(monthsStr: string)

Source from the content-addressed store, hash-verified

1088 cache[cacheKey] = { data, timestamp: Date.now() };
1089 localStorage.setItem(CROP_PLAN_CACHE_KEY, JSON.stringify(cache));
1090}
1091
1092function parseMonthRange(monthsStr: string): number[] {
1093 const parts = monthsStr.split("-").map((s) => s.trim().substring(0, 3));
1094 if (parts.length !== 2) return [];
1095 const startIdx = MONTHS.findIndex((m) => m.toLowerCase() === parts[0].toLowerCase());
1096 const endIdx = MONTHS.findIndex((m) => m.toLowerCase() === parts[1].toLowerCase());
1097 if (startIdx === -1 || endIdx === -1) return [];
1098
1099 const indices: number[] = [];
1100 if (startIdx <= endIdx) {
1101 for (let i = startIdx; i <= endIdx; i += 1) indices.push(i);
1102 } else {
1103 for (let i = startIdx; i < 12; i += 1) indices.push(i);
1104 for (let i = 0; i <= endIdx; i += 1) indices.push(i);
1105 }
1106 return indices;
1107}
1108

Callers 1

CropPlanningSectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected