MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / parseMonthIndex

Function parseMonthIndex

packages/core/src/query/contact-scoring.ts:69–78  ·  view source on GitHub ↗
(month: string)

Source from the content-addressed store, hash-verified

67}
68
69function parseMonthIndex(month: string): number | null {
70 const match = /^(\d{4})-(\d{2})$/.exec(month)
71 if (!match) return null
72
73 const year = Number.parseInt(match[1], 10)
74 const monthNumber = Number.parseInt(match[2], 10)
75 if (!Number.isFinite(year) || monthNumber < 1 || monthNumber > 12) return null
76
77 return year * 12 + monthNumber - 1
78}
79
80function getActiveMonthIndexes(activeMonths: readonly string[]): number[] {
81 return [...new Set(activeMonths.map(parseMonthIndex).filter((month): month is number => month !== null))].sort(

Callers

nothing calls this directly

Calls 1

execMethod · 0.65

Tested by

no test coverage detected