mantinedev/mantine · error · Error

[@mantine/schedule] Event end date is before start date for

Error message

[@mantine/schedule] Event end date is before start date for event id: ${eventData.id}

What it means

validateEvent requires events to be chronological: dayjs(event.end).isBefore(dayjs(event.start)) must be false. A negative duration makes overlapping/layout calculations meaningless, so the library throws with the offending event id.

Source

Thrown at packages/@mantine/schedule/src/utils/validate-event/validate-event.ts:14

import dayjs from 'dayjs';
import { ScheduleEventData } from '../../types';

export function validateEvent(eventData: ScheduleEventData) {
  if (!dayjs(eventData.start).isValid()) {
    throw new Error(`[@mantine/schedule] Invalid start date for event id: ${eventData.id}`);
  }

  if (!dayjs(eventData.end).isValid()) {
    throw new Error(`[@mantine/schedule] Invalid end date for event id: ${eventData.id}`);
  }

  if (dayjs(eventData.end).isBefore(dayjs(eventData.start))) {
    throw new Error(
      `[@mantine/schedule] Event end date is before start date for event id: ${eventData.id}`
    );
  }

  return eventData;
}

View on GitHub (pinned to 8a284e2c2c)

Solutions

  1. Swap start/end if they are inverted at the mapping layer
  2. Validate and clamp ranges (end = max(start, end)) before rendering
  3. For timezone bugs, normalise both bounds to the same timezone/UTC before comparison

Example fix

// before
{ id: '1', start: '2025-01-10T15:00', end: '2025-01-10T14:00' }

// after
{ id: '1', start: '2025-01-10T14:00', end: '2025-01-10T15:00' }
Defensive patterns

Strategy: validation

Validate before calling

const normalized = events.map((e) => {
  const start = dayjs(e.start);
  const end = dayjs(e.end);
  return end.isBefore(start) ? { ...e, start: end.toISOString(), end: start.toISOString() } : e;
});

Type guard

const isChronological = (e: ScheduleEventData): boolean =>
  !dayjs(e.end).isBefore(dayjs(e.start));

Prevention

When it happens

Trigger: end earlier than start (e.g. start '2025-01-10T15:00' with end '2025-01-10T14:00'), often after timezone conversion shifts one bound, or after swapping start/end fields when mapping API data.

Common situations: DST/timezone shifts making a same-instant range appear inverted, swapped API field mapping, drag-to-resize gesture producing a negative range, or 12h/24h AM-PM mix-ups in a form.

Related errors


AI-assisted analysis of mantinedev/mantine@8a284e2c2c (2026-08-28). Data as JSON: /api/errors/7271acf8d67a100f. Report an issue: GitHub.