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 const cached = localStorage.getItem(CROP_PLAN_CACHE_KEY);
1089 return cached ? JSON.parse(cached) : {};
1090 } catch {
1091 return {};
1092 }
1093}
1094
1095function setPlanCache(cacheKey: string, data: CropPlan) {
1096 const cache = getPlanCache();
1097 cache[cacheKey] = { data, timestamp: Date.now() };
1098 localStorage.setItem(CROP_PLAN_CACHE_KEY, JSON.stringify(cache));
1099}
1100
1101function parseMonthRange(monthsStr: string): number[] {
1102 const parts = monthsStr.split("-").map((s) => s.trim().substring(0, 3));
1103 if (parts.length !== 2) return [];
1104 const startIdx = MONTHS.findIndex((m) => m.toLowerCase() === parts[0].toLowerCase());
1105 const endIdx = MONTHS.findIndex((m) => m.toLowerCase() === parts[1].toLowerCase());
1106 if (startIdx === -1 || endIdx === -1) return [];
1107
1108 const indices: number[] = [];

Callers 1

CropPlanningSectionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected