MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / cronDomMatchesNow

Function cronDomMatchesNow

packages/server/src/services/schedule/utils.ts:415–442  ·  view source on GitHub ↗
(cronExpression: string, date: Date = new Date(), timezone: string = 'UTC')

Source from the content-addressed store, hash-verified

413 * original expression contains no `L` (no filtering needed).
414 */
415export const cronDomMatchesNow = (cronExpression: string, date: Date = new Date(), timezone: string = 'UTC'): boolean => {
416 const parsed = _parseCronFields(cronExpression)
417
418 // Extract DOM, month, year in the schedule's timezone so leap-year and
419 // DST month boundaries are honoured.
420 let dom: number, month: number, year: number
421 try {
422 const fmt = new Intl.DateTimeFormat('en-US', {
423 timeZone: timezone,
424 year: 'numeric',
425 month: 'numeric',
426 day: 'numeric'
427 })
428 const parts = fmt.formatToParts(date)
429 const get = (type: string) => parseInt(parts.find((p) => p.type === type)?.value ?? '0', 10)
430 dom = get('day')
431 month = get('month')
432 year = get('year')
433 } catch {
434 dom = date.getUTCDate()
435 month = date.getUTCMonth() + 1
436 year = date.getUTCFullYear()
437 }
438
439 // Day 0 of next month == last day of current month.
440 const lastDay = new Date(year, month, 0).getDate()
441 return _matchDomField(parsed.domField, dom, lastDay)
442}
443
444// ─── Visual Picker helpers ────────────────────────────────────────────────────
445

Callers 2

utils.test.tsFile · 0.90
_upsertCronJobMethod · 0.90

Calls 3

_parseCronFieldsFunction · 0.85
getFunction · 0.85
_matchDomFieldFunction · 0.85

Tested by

no test coverage detected