MCPcopy Create free account
hub / github.com/simstudioai/sim / getTimeRange

Function getTimeRange

apps/sim/connectors/google-calendar/google-calendar.ts:167–193  ·  view source on GitHub ↗

* Parses the date range config into timeMin/timeMax values.

(sourceConfig: Record<string, unknown>)

Source from the content-addressed store, hash-verified

165 * Parses the date range config into timeMin/timeMax values.
166 */
167function getTimeRange(sourceConfig: Record<string, unknown>): { timeMin: string; timeMax: string } {
168 const dateRange = (sourceConfig.dateRange as string) || 'default'
169
170 const now = new Date()
171
172 switch (dateRange) {
173 case 'past_only': {
174 const past = new Date(now)
175 past.setDate(past.getDate() - DEFAULT_RANGE_DAYS)
176 return { timeMin: past.toISOString(), timeMax: now.toISOString() }
177 }
178 case 'future_only': {
179 const future = new Date(now)
180 future.setDate(future.getDate() + DEFAULT_RANGE_DAYS)
181 return { timeMin: now.toISOString(), timeMax: future.toISOString() }
182 }
183 case 'past_90': {
184 const past = new Date(now)
185 past.setDate(past.getDate() - 90)
186 const future = new Date(now)
187 future.setDate(future.getDate() + 90)
188 return { timeMin: past.toISOString(), timeMax: future.toISOString() }
189 }
190 default:
191 return getDefaultTimeRange()
192 }
193}
194
195/**
196 * Converts a CalendarEvent to an ExternalDocument.

Callers 1

google-calendar.tsFile · 0.85

Calls 1

getDefaultTimeRangeFunction · 0.85

Tested by

no test coverage detected