Issue Bug Closed

#109819Backend datetime picker renders broken calendar grid when dateTimeFirstDayOfWeek is unset in uc

Oliver Heins 05/11/26, 15:13 updated 08/11/26, 08:50

Description

Summary

After Feature #108463 (“User-specific configuration of date-timepicker’s first day of a week”, introduced in 14.1), the backend date-time picker renders a broken calendar grid for any backend user whose be_users.uc does not contain a dateTimeFirstDayOfWeek entry — which is the default state for every user that hasn’t opened the User Settings module since the upgrade.

In the broken state, the calendar lays the days out sequentially starting in the leftmost column: the 1st of every month appears in column 0, the 2nd in column 1, etc., regardless of the actual weekday. The week header is rendered correctly, so the misalignment is immediately visible (e.g. December 1st 2026 is shown under “Sun” although it is a Tuesday).

Affected versions

  • TYPO3 >= 14.1 (since Feature #108463 — User-specific configuration of date-timepicker’s first day of a week)

Steps to reproduce

  1. On a clean 14.x install (or an upgraded site), use a BE user whose uc does not yet contain dateTimeFirstDayOfWeek. The simplest way: create a fresh BE user and log in once.
  2. Open any record with a TCA type=datetime field.
  3. Open the picker and navigate between months.

Expected

The 1st of each month is rendered in the column matching its actual weekday (e.g. Dec 1 2026 in the Tuesday column, Feb 1 2026 in the Sunday column).

Actual

The 1st of every month appears in column 0 (“Sun” with ‘en’ locale). Days 2..N fill the remaining cells sequentially. The previous-month padding cells are absent entirely.

Root cause

typo3/sysext/backend/Resources/Public/JavaScript/storage/persistent.js returns undefined (not "") when a key is missing from uc — see the deep-key lookup in getRecursiveDataByDeepKey() and the dedicated isset() helper which checks for both undefined and null.

typo3/sysext/backend/Build/Sources/TypeScript/backend/date-time-picker.ts (lines 64-75) only guards against the empty string:

const dow = Persistent.get('dateTimeFirstDayOfWeek');
if (dow !== '') {
  const dowNumber = parseInt(dow, 10) - 1;
  flatpickr.l10ns[locale].firstDayOfWeek = dowNumber;
  flatpickr.l10ns.default.firstDayOfWeek = dowNumber;
}

With dow === undefined, the branch executes, parseInt(undefined, 10) - 1 evaluates to NaN, and firstDayOfWeek is assigned NaN.

In flatpickr’s buildDays() the leading-day offset is then (date.getDay() - NaN + 7) % 7 === NaN, so the prev-month padding loop for (var u = o + 1 - NaN; u <= o; ...) never executes and days are appended into a grid with no leading offset.

Proposed fix

Tighten the guard to also reject undefined / null:

const dow = Persistent.get('dateTimeFirstDayOfWeek');
if (dow !== '' && dow !== undefined && dow !== null) {
  const dowNumber = parseInt(dow, 10) - 1;
  flatpickr.l10ns[locale].firstDayOfWeek = dowNumber;
  flatpickr.l10ns.default.firstDayOfWeek = dowNumber;
}

Workaround

For an upgraded site: set a system-wide override in User TSConfig until users have populated their preferences:

setup.override.dateTimeFirstDayOfWeek = 2

Note: setup.default.* is insufficient because that only applies to users who have never logged in.

Reviews 2

History 26

  1. Garvin Hicking commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-05-12T09:05:11+00:00" > 05/12/26, 09:05 </span>

    Applied in changeset commit:df991295544a71331872f9146e9459776a1aca7c.