Volto 18: single-day "whole day" events can't be saved

While setting up events on a client site we found that an editor can't save a whole-day event that starts and ends on the same day. Tick "Whole Day", set 2 December to 2 December, and the form refuses to save:

Event start date must be on or before 02 Dec 2026, 02:00
Event end date must be on or after 02 Dec 2026, 02:00

The message says "on or before", and the dates are equal, so the editor has done exactly what it asks.

Diagnosis

The block happens in the browser, before anything reaches the backend. Volto 18 registers two client-side validators for plone.eventbasic in helpers/FormValidation/validators.ts, and both use strict comparisons:

// startEventDateRangeValidator
value && formData.end && new Date(value) < new Date(formData.end);

// endEventDateRangeValidator
value && formData.start && new Date(value) > new Date(formData.start);

With "Whole Day" ticked, DatetimeWidget sends both dates as YYYY-MM-DD. Same day, same string, same timestamp, so neither check passes. (The "02:00" in the message is midnight UTC shown in South African time.)

It isn't only whole-day events. Any event with an identical start and end time fails the same way.

The backend is fine with equal dates. plone.app.event's invariant only rejects start > end.

We saw this on Volto 18.35.0, and the code on main is the same today.

Workaround

Volto's validators are registry utilities, and registering a utility with the same name and dependencies replaces it. Add-on configuration loads after Volto's own, so in your add-on's config:

import { messages } from '@plone/volto/helpers/MessageLabels/MessageLabels';

const formatDateValue = (isoString) => {
  const date = new Date(isoString);
  if (isNaN(date.getTime())) return isoString;
  return new Intl.DateTimeFormat(undefined, {
    dateStyle: 'medium',
    timeStyle: 'short',
  }).format(date);
};

const startEventDateRangeValidator = ({ value, formData, formatMessage }) => {
  const isValid =
    value && formData.end && new Date(value) <= new Date(formData.end);
  return !isValid
    ? formatMessage(messages.startEventRange, {
        endDateValueOrEndFieldName: formData.end
          ? formatDateValue(formData.end)
          : 'end',
      })
    : null;
};

const endEventDateRangeValidator = ({ value, formData, formatMessage }) => {
  const isValid =
    value && formData.start && new Date(value) >= new Date(formData.start);
  return !isValid
    ? formatMessage(messages.endEventRange, {
        startDateValueOrStartFieldName: formData.start
          ? formatDateValue(formData.start)
          : 'start',
      })
    : null;
};

export default function applyConfig(config) {
  config.registerUtility({
    name: 'dateRangeValidator',
    type: 'validator',
    dependencies: { behaviorName: 'plone.eventbasic', fieldName: 'start' },
    method: startEventDateRangeValidator,
  });
  config.registerUtility({
    name: 'dateRangeValidator',
    type: 'validator',
    dependencies: { behaviorName: 'plone.eventbasic', fieldName: 'end' },
    method: endEventDateRangeValidator,
  });
  return config;
}

The only change from Volto's version is <= and >=.

Upstream

The real fix is those two characters in Volto. I'm happy to open the PR unless someone knows of a reason the comparison was made strict.

I'd create the issue in Issues · plone/volto · GitHub since it doesn't look to have been reported before, then go ahead and create a PR :mechanical_arm:

Just noticed that you said Volto 18, so would be worth checking if the same issue is in Volto 19

It's a bug.

Make sure to add it to the PLIP project board.

Note that "whole day" events should have no start or end time added, as they have the implicit start of 0:00:00 and end of 23:59:59 of the locale.

See also PLIP: Event end date should comply with RFC 5545 iCalendar · Issue #4310 · plone/Products.CMFPlone · GitHub. It has more information about how this should be handled.