MCPcopy
hub / github.com/simstudioai/sim / parseOneTimeRun

Function parseOneTimeRun

apps/sim/lib/workflows/schedules/orchestration.ts:101–127  ·  view source on GitHub ↗
(time: string, timezone: string)

Source from the content-addressed store, hash-verified

99 )
100
101function parseOneTimeRun(time: string, timezone: string): Date | null {
102 let timeStr = time
103 const hasOffset = /[Zz]|[+-]\d{2}(:\d{2})?$/.test(timeStr)
104 if (!hasOffset && timezone !== 'UTC') {
105 try {
106 const formatter = new Intl.DateTimeFormat('en-US', {
107 timeZone: timezone,
108 timeZoneName: 'shortOffset',
109 })
110 const parts = formatter.formatToParts(new Date())
111 const offsetPart = parts.find((part) => part.type === 'timeZoneName')
112 const match = offsetPart?.value.match(/GMT([+-]\d{1,2}(?::\d{2})?)/)
113 if (match) {
114 const [rawHours, rawMinutes = '00'] = match[1].split(':')
115 const sign = rawHours.startsWith('-') ? '-' : '+'
116 const hour = Number(rawHours.replace(/^[+-]/, ''))
117 if (Number.isFinite(hour)) {
118 const offset = `${sign}${String(hour).padStart(2, '0')}:${rawMinutes.padStart(2, '0')}`
119 timeStr = `${timeStr}${offset}`
120 }
121 }
122 } catch {}
123 }
124
125 const parsed = new Date(timeStr)
126 return Number.isNaN(parsed.getTime()) ? null : parsed
127}
128
129export async function performCreateJob(
130 params: PerformCreateJobParams

Callers 2

performCreateJobFunction · 0.85
performUpdateJobFunction · 0.85

Calls 2

testMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected