Skip to content
This repository was archived by the owner on Nov 4, 2026. It is now read-only.

Commit 4f8b7f8

Browse files
fix(plugin-calendar,plugin-gantt): show a stored date-only day on that day and write a date field as the calendar day (objectui#10866, sites 1 and 2) (#10886)
Part of #10866 Clause-②: no Every read goes through the existing `toDisplayDate`, and a write to a `date` field sends the spec's own `YYYY-MM-DD` storage form. No declared key, export or accept set moves. `@object-ui/types` changes one description string. ## What changed This is slice 1 of the date-only zone family's successor card: sites 1 and 2, per triage `5861646819` item 1. It covers the calendar and the gantt, and in each plugin the reads and the writes change together. Sites 3 to 6 are later slices, listed under Acceptance notes. **Reads: every stored date-only value now goes through `toDisplayDate` from `@object-ui/core`.** That function reads a date-only value at local midnight of the day it names. A value with a time keeps its instant. - plugin-calendar `ObjectCalendar`: the event `start` and `end`. - plugin-calendar `calendar-view` renderer: each event's `start` and `end`, and the authored `currentDate` (`resolveAuthoredCurrentDate`). - plugin-gantt `ObjectGantt`: the task `start` and `end`, and `baselineStart` / `baselineEnd` (new helper `readTaskDate`). - plugin-gantt `GanttView`: a marker's `date`, in both the zoned `markers` memo and `resolvedMarkers`, and the inline editor's committed start and end. **Writes: a `date` field is written as the calendar day.** This covers the calendar drop (`handleEventDropDefault`), the calendar quick-create (`submitQuickCreate`) and the gantt drag (`handleTaskUpdateDefault`). - A field declared `date` is written as the local calendar day `yyyy-MM-dd`, using core's `toDateInputValue`. - Any other declared type (`datetime`) keeps `toISOString()`. - With no object schema to ask, the stored value's own shape decides (`isRealCalendarDate`). That is the same split the read makes, so the read and the write cannot disagree. - A quick-create has no stored value, so on a field with no declared type it still writes the instant. - New private helper `toStoredDateValue`, one in each plugin. **The gantt `timeZone`.** The card asked for a decision on `tzShift`'s treatment of a date-only value. The decision: a date-only day stands on that day of the chart's own calendar, for every viewer, and a drop writes the day of the chart's calendar it landed on. - `GanttView` re-bases every `Date` it is handed into the business zone, and translates every emitted change back. - `ObjectGantt` therefore hands it the instant that re-bases onto the named day's local midnight (`readTaskDate`). It reads a drop back through the same shim before taking the local day (`toStoredDateValue`). - A date-only marker is placed on its day and is not re-based. - With no `timeZone` both halves are the identity. That is the showcase's case and every chart's default. - Two alternatives were not taken: - A per-task "this is a day" flag on `GanttTask` would widen an exported type (a public face, Clause-② yes). - Leaving days re-based like instants puts the bar on the previous day for any viewer east of the chart's zone. **The gantt working calendar (`skipWeekends` / `holidays`, `scheduling.ts`).** The scheduler floored to UTC midnight and keyed days with `getUTCDay` / `toISOString()`. That only agreed with a date-only value while the value was read as UTC midnight. - It now floors to local midnight and steps by calendar day. It keys days the way `GanttView`'s own column fold (`isWorkingColumn`) already did. - Left on UTC, a rescheduled successor landed a day early in every zone except UTC (see H1). **Also moved:** - `makeTzShift` moved unchanged out of `GanttView.tsx` into a new `plugin-gantt/src/tzShift.ts`, and `GanttView` re-exports it. The reason is that `ObjectGantt` now calls it, and the `ObjectGantt` suites replace `./GanttView` with a probe (`vi.mock('./GanttView', …)`). Imported from there, it was undefined in each of those suites: the first full run went red with `No "makeTzShift" export is defined on the "./GanttView" mock`. - Two `ObjectGantt.test.tsx` cases pinned the defect. They expected a drag to write `2024-02-01T00:00:00.000Z` into a field declared `date` (on the api provider, a field stored as `2024-01-01`). They now expect `2024-02-01`. Both carry a comment saying so. - `@object-ui/types`: the `holidays` JSDoc and its zod `.describe()` said the keys were UTC days. This change made that false, so both now say calendar days on the chart's own calendar. This is an in-place fix under the bounded exemption: - It is the same defect class, a one-phrase fix. - No open PR touches `objectql.ts` or `objectql.zod.ts`. I read the open-PR file lists at 2026-09-28T02:18Z and again at 03:11Z; the only file hit anywhere near this change is the release PR's CHANGELOGs. - It uses the same gate family. - The changeset names `@object-ui/types` as a `patch` for it. **Fix round 1, at `687890effa`.** CI on `8ac7b62270` went red in `Test (shard 7/8)` on the objectui#9909 locale census (`machineLocaleCensus-9909.test.ts`). The contract review on that commit asked for three more changes. - **The census entry follows the shim.** Moving `makeTzShift` also moved a DECLARED site: `tzOffsetMs`'s `en-US` `formatToParts` parser, which never renders text. The census reported `GanttView.tsx · new Intl.DateTimeFormat('en-US', { — declared 1, found 0` and an undeclared `[en-US]` site in `tzShift.ts`. That `DECLARED` entry now names `packages/plugin-gantt/src/tzShift.ts`. Its expression, count (1), verdict and reason are unchanged. The root `vitest.config.mts` comment that cited `tzOffsetMs` by its file is re-pointed the same way. - **Literal-anchor sweep of the move.** I grepped tests, scripts and ledgers for `GanttView.tsx` together with `makeTzShift`, `tzOffsetMs` or `Intl.DateTimeFormat('en-US'`. The census entry and that config comment were the only hits. The other `GanttView.tsx` ledgers (`residue-namespaces-3546`, `gantt-count-interpolation-4157`, `check-i18n-call-site-keys.mjs`) name i18n keys and union types, which did not move. - **`GanttViewProps.workingCalendar` (exported).** Its JSDoc still said `holidays` were UTC keys. It now says they are calendar-day keys read on the chart's own calendar: the viewer's, or the business `timeZone`'s when one is set. - **Other UTC working-day rule sites.** I swept plugin-gantt, plugin-calendar, types, `content/docs` and `skills` for UTC wording about holidays, weekends or working days. Two more encoded the retired rule, and both now read the local day: - `scheduling.test.ts`'s weekend count (`getUTCDay`). It is equivalent under the suite's pinned `TZ=UTC`. - `packages/plugin-gantt/scripts/verify-phase6b.mjs`'s weekend-start check. This is a manual Playwright script, not run by CI; its browser context sets no `timezoneId`, so the page and the script share one zone. - **Changeset.** The Writes bullet now ends: a calendar quick-create has no stored value, so there it still writes the instant. The frontmatter is byte-identical. - **Files this round:** `packages/i18n/src/__tests__/machineLocaleCensus-9909.test.ts`, `vitest.config.mts` (comment), `packages/plugin-gantt/src/GanttView.tsx` (JSDoc), `packages/plugin-gantt/src/scheduling.test.ts`, `packages/plugin-gantt/scripts/verify-phase6b.mjs` and `.changeset/10866-calendar-gantt-date-only-days.md`. ## H1 and H2 **H1, measured on base.** The new pins were added over the base source (`b93e245f9`, source unchanged) and run in the objectui#10183 driver's forks child. Controls, west = `America/Los_Angeles`, east = `Asia/Shanghai`: - **Calendar, west.** `2026-10-05` sat in the `October 4, 2026` cell. A two-day move wrote `'2026-10-07T00:00:00.000Z'`. A quick-create on the 12th wrote `'2026-10-12T07:00:00.000Z'`. - **Calendar, east.** The read was already right. A move wrote `'2026-10-07T00:00:00.000Z'`. A quick-create on the 12th wrote `'2026-10-11T16:00:00.000Z'`, which names the 11th. - **`calendar-view`, west.** `currentDate: '2026-11-01'` opened on October, and `2026-11-05` sat on the 4th. - **Gantt reads.** The task start read as year, month, day, hour `[2026, 10, 4, 17]` west and `[2026, 10, 5, 8]` east. - **Gantt writes.** A drag wrote `toISOString()` instants into both `date` fields. - **Zoned charts.** A west viewer of a chart zoned `Asia/Shanghai` got the bar at `[2026, 10, 5, 8]`. An east viewer of a chart zoned `America/Los_Angeles` got `[2026, 10, 4, 17]`. - **Markers.** A `2026-10-05` marker stood 32 px (west) and 37 px (east) off the edge of a bar starting that day. - **Inline editor.** A typed `2026-10-07` was committed as `[2026, 10, 6, 17]` west and `[2026, 10, 7, 8]` east. - **Working calendar.** A successor of a Friday task landed at `[2026, 10, 11, 17]` (a Sunday) west, and at `[2026, 10, 9, 8]` (the Friday itself) east. - **`datetime` controls, green on base and on head.** The instant `2026-10-06T04:00:00.000Z` sits on its local day in each zone. A two-day move writes `2026-10-08T04:00:00.000Z` in both zones, and a gantt drag keeps the instant. **H2, the census.** It covers the non-test sources of both plugins, searching for `new Date(`, `toISOString(` and `Date.parse(`. Neither plugin imports a date-fns parse. Each site is classified by the field it serves. Date-only (a stored `Field.date` value, or an authored day). All are fixed here: - `ObjectCalendar`: event start and end; drop patch; quick-create payload. - `calendar-view` renderer: event start and end; `currentDate`. - `ObjectGantt`: task start and end; baselines; drag patch. - `GanttView`: marker date, 2 sites; inline editor start and end. - `scheduling.ts`: the UTC day key and the UTC floor. Datetime, or not a stored value, and so left as is: - `ObjectGantt`: the tooltip's datetime sniff, which is a validity check on a datetime-shaped string. The `new Date()` placeholder for a date-less record. The `lockedRange` min/max copies. - `CalendarView`: every `new Date(x)` copies a `Date`. Its props are typed `Date`, and the day math uses local getters and multi-argument constructors. - `GanttView`: the `tzShift` shim, `now()`, copies and arithmetic. The `startDate` / `endDate` props are typed `Date`. - `calendar-view` renderer: the registry's sample events (demo data built from `new Date()`). - `ResourceWorkload`, `shifts.ts`, and the rest of `scheduling.ts`: copies and millisecond arithmetic. - `ObjectCalendar`: the clock (`useState(new Date())`, `handleCreate`). ## Pins and ablation **Five new pins, registered in the objectui#10183 driver's `PINS`.** - `ObjectCalendar.dateOnlyZone-10866.test.tsx`: the read cell, a two-day move and a quick-create, with `datetime` controls. - `calendarViewRenderer.dateOnlyZone-10866.test.tsx`: events and `currentDate`. - `ObjectGantt.dateOnlyZone-10866.test.tsx`: reads with baselines, the drag payload, and a zoned chart read and written, with `datetime` controls. - `GanttView.dateOnlyZone-10866.test.tsx`: markers, unzoned and zoned, and the inline editor. - `scheduling.dateOnlyZone-10866.test.ts`: the weekend and a holiday. How the pins run: - Each zone opens with a rig case. - The suite-zone cases also run in the normal run. They assert the written shape, which UTC can tell apart. **Red on base, green on head.** On base the driver gave `Tests 6 failed | 8 passed (14)`: all 5 new pin rows plus the child-exit row, and the 8 existing pins stayed green. The failed cases were: - every date-only read case, west, plus the east gantt read and markers; - every date-only write case, both zones; - both zoned-chart cases; - both inline-editor cases; - all 4 working-calendar cases. The rigs and the `datetime` controls passed. **Ablation (read routing reverted), at `f9ae4ebd7b`.** I committed first, then used `ablation-replace.mjs --hold` with 10 anchors, each asserted `x1 → x0` with a changed blob. They set every read above back to `new Date(…)`: 2 in `ObjectCalendar`, 3 in the `calendar-view` renderer, 1 in `readTaskDate`, and 4 in `GanttView`. No `dist` is involved: the vitest root config resolves `@object-ui/*` to `src`, and the plugin files are imported relatively. The driver went `Tests 5 failed | 9 passed (14)`. - **Red:** the calendar read (west), the `calendar-view` read (west), the gantt read in both zones, both zoned-chart cases, and all 4 marker cases and both inline-editor cases. - **Green:** every pure write case, meaning the gantt drag onto the 7th in both zones, all quick-creates, and the calendar east move. All `datetime` controls and the working calendar also stayed green. - **One write row reddened, as a cascade: the west calendar move.** It moves the event two days from the cell it was drawn in, so with the read reverted it wrote `'2026-10-06'`. That is still a day, not an instant, just one day early. - **Restore.** Each file was restored with `git checkout HEAD --` to its HEAD blob (`68688411c93a`, `26454aa22622`, `266f62c9ecdb`, `257811400efc`), and `git diff HEAD` was empty. ## Gates **Fix round 1, at `687890effa`.** - **Census red reproduced first**, at `8ac7b62270` under the verify lock: `Tests 2 failed | 5 passed (7)`, with exactly the two CI messages. - **The census, now green.** Run under the lock with the zone-pin driver and the 12 script pins that read `vitest.config.mts`: `Test Files 16 passed (16)`, `Tests 566 passed (566)`. The census alone gives `Tests 7 passed (7)`. - **plugin-calendar + plugin-gantt**, under the lock: `Test Files 137 passed (137)`, `Tests 974 passed | 44 skipped (1018)`. That run does not include the driver, which ran in the census run above. - **Gates, each exit 0:** `check-changeset-presence` / `-no-major` / `-claims` / `-fixed` / `-overwrite`, `check-pending-changeset-literals`, `check-new-cross-file-line-citations` (`0 new citation(s)`), `check-control-bytes` and `check-unreferenced-sources`. `check-governed-queue-guard --test` over the 20 changed paths answers NOT GOVERNED. - **ESLint, narrowed:** the 5 files this round touched. 0 errors, and each file's warning count equals its count at `8ac7b62270`. - **NOT MEASURED: type-check, this round.** The re-created worktree has no built dependency closure. The round's type-level change is `getUTCDay` to `getDay` in one test; the rest is comments, one JSDoc and a string path. CI's `Type Check` covers it. **Round 0.** The gates and ESLint ran at `8ac7b62270`; the type-check and the two package-suite runs name their own commit. **Type-check, at `3587ab1a02`.** First the closure (`pnpm --workspace-concurrency=2 --filter '@object-ui/plugin-calendar^...' --filter '@object-ui/plugin-gantt^...' run build`: lock verdict `command-exit 0`). Then `pnpm --workspace-concurrency=2 --filter @object-ui/plugin-calendar --filter @object-ui/plugin-gantt --filter @object-ui/types run type-check`: - each package echoes its `type-check$ tsc --noEmit … && tsc -p tsconfig.test.json` and prints Done; - `pnpm type-check:scripts` exits 0; - the gantt test project was re-run after the last commit, `tsc -p tsconfig.test.json --noEmit`, exit 0. The test tsconfigs include `src/**/*.test.ts(x)`. **Suites.** - At `3587ab1a02`: `pnpm exec vitest run packages/plugin-calendar/ packages/plugin-gantt/ scripts/__tests__/date-only-zone-pins-10183.test.ts` gave `Test Files 138 passed (138)`, `Tests 988 passed | 44 skipped (1032)`. The 44 skipped are the new zone cases, which run in the driver's child. - `packages/types/` gave `Test Files 257 passed (257)`, `Tests 5482 passed (5482)`. - The last commit only types the gantt pin. After it, the driver, the five pins, `ObjectGantt.test.tsx` and `GanttView.tzshift.test.ts` gave `Test Files 8 passed (8)`, `Tests 64 passed | 44 skipped (108)`. **Gates, each exit 0.** - `check-changeset-presence`, `-no-major`, `-claims`, `-fixed` and `-overwrite`. - `check-pending-changeset-literals`. - `check-new-cross-file-line-citations`, which prints `VERDICT new-cross-file-line-citations: 0 new citation(s)`. - `check-control-bytes`, `check-test-path-roots`, and `check-vi-mock-specifiers` / `-inherit` / `-override-shape`. - `check-phantom-dependencies`, `check-unused-dependencies` and `check-unreferenced-sources`. - `check-governed-queue-guard --test` over the 16 changed paths answers NOT GOVERNED. **ESLint, narrowed.** The repo-wide run belongs to CI. - **What was run:** the root `eslint.config.js` with `--no-inline-config --format json` over the 15 changed code files; the JSON holds 15 file results. - **Result:** 0 errors. Each modified file's warning count equals its base count (via `--stdin` on the base blob): `ObjectCalendar` 31, the `calendar-view` renderer 1, `GanttView` 12, `ObjectGantt` 84, `ObjectGantt.test.tsx` 30, `scheduling.ts` 0, `objectql.ts` 34, `objectql.zod.ts` 1, the driver 0. The new files have 0 each. - **Why narrowing is safe:** the config sets no `parserOptions.project` or `projectService`, so it is not type-aware and this diff cannot move a verdict on an untouched file. **Pending changesets.** I read every pending changeset that names a file or symbol this change touches. `check-changeset-claims` lists 35 by file. None states the behaviour changed here: date reads, instant writes, UTC holiday keys, or the zone shim. No note is owed. ## Serial - **Claim.** The earliest live `Claim:` on the card is `5861874880` (seat 2, this PR). A later claim, `5861881966` (seat 4, site 1 only), names branch `claude/issue-10866-calendar-date-only`. That branch did not exist on the remote when this one was cut, and nothing here touches it. - **Open PRs.** At 2026-09-28T02:18Z and again at 03:11Z, no open PR touched `packages/plugin-calendar`, `packages/plugin-gantt`, `packages/types/src/objectql.ts`, `packages/types/src/zod/objectql.zod.ts` or the zone-pin driver, apart from the release PR's CHANGELOG and `package.json` lines. - **Merge order.** The next slices of #10866 register in the same `PINS` list, so they are serial after this PR. ## Acceptance notes **#10866 remains open; sites 3 to 6 are later slices.** - `plugin-timeline`: `ObjectTimeline.dateBucket`, the sort, the renderer's `formatDate` default face and the axis extent. - `plugin-charts`: `AdvancedChartImpl.formatTick` and its `toISOString()` fallback. - Core `FormulaFunctions`: `DATEADD` / `DATEDIFF` / `DATEFORMAT` against `TODAY()` / `NOW()`. Triage requires one zone decision, measured against the server formula engine. - The i18n helpers: `formatDate`, `formatDateTime`, `formatRelativeTime` and `formatDateSpec`. **Observed, not filed.** Each is a read-only inference, not measured. - **Calendar drop across a DST change.** `CalendarView`'s move adds the millisecond delta between two local midnights to the event's start. Suppose an event starts on the 25-hour day (the first Sunday of November, west), and is grabbed from a later cell of its span. The new start then lands at 23:00 of the day before the target, and a `date` field is written as that day. This is pre-existing arithmetic: a `datetime` event moves by an hour on the same path. - **Business-zone day placement near DST.** It inherits `makeTzShift`'s per-instant offsets, which the shim documents as close rather than exact near a DST transition in either zone. - **Date-only end is exclusive.** A date-only gantt end reads as that day's start, so the bar ends where the end day begins. This is unchanged by this PR. Written by the `domain:ui#2` dispatch, session `https://claude.ai/code/session_014mXUNuFomfj24w7s1pZzhN`. --- _Generated by [Claude Code](https://claude.ai/code/session_014mXUNuFomfj24w7s1pZzhN)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 45dbf1c commit 4f8b7f8

20 files changed

Lines changed: 1310 additions & 105 deletions
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/plugin-calendar': patch
3+
'@object-ui/plugin-gantt': patch
4+
'@object-ui/types': patch
5+
---
6+
7+
fix(plugin-calendar,plugin-gantt): a stored date-only day shows on that day in every viewer zone, and a `date` field is written back as a calendar day (objectui#10866, slice 1)
8+
9+
The calendar and the gantt read a record's `YYYY-MM-DD` value with the engine's own `Date` parse, which reads it as UTC midnight. West of UTC a task due on the 5th therefore showed on the 4th, in both views. Moving it then wrote `toISOString()` into the field: a UTC instant stored in a `Field.date`.
10+
11+
- **Reads.** Every date-only read in the two plugins now goes through `toDisplayDate` from `@object-ui/core`, which reads the value at local midnight of the day it names. In the calendar these are the object calendar's event start and end, and the `calendar-view` node's events and its authored `currentDate`. In the gantt they are the task start, end and baselines, a marker authored as a day, and the day typed into the inline editor. A value with a time keeps its instant.
12+
- **Writes.** A calendar drop, a calendar quick-create and a gantt drag now write a field declared `date` as the local calendar day, `yyyy-MM-dd`. A `datetime` field keeps its instant. When no object schema is available to say which type a field is, the stored value's own shape decides, which is the same split the read makes; a calendar quick-create has no stored value, so there it still writes the instant.
13+
- **Gantt `timeZone`.** A chart with a business `timeZone` re-bases every instant into that zone. A date-only day is not re-based: its bar and its marker stand on that day of the chart's calendar for every viewer, and a drop writes the day of the chart's calendar that the bar was dropped on.
14+
- **Gantt working calendar.** `skipWeekends` / `holidays` now count the chart's own calendar days (local midnight, the same keys the day columns already folded by) rather than UTC days. The UTC floor put a rescheduled successor on the previous day in every zone except UTC once date-only values read as local days. `@object-ui/types` updates the `holidays` description to match.
15+
16+
The timeline, charts, formula date functions and i18n helpers are later slices of objectui#10866.

‎packages/i18n/src/__tests__/machineLocaleCensus-9909.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ const DECLARED: Exemption[] = [
301301
reason: 'the end-date twin of the ISO-8601 formatter above, feeding the second `<input type="date">`.',
302302
},
303303
{
304-
file: 'packages/plugin-gantt/src/GanttView.tsx',
304+
file: 'packages/plugin-gantt/src/tzShift.ts',
305305
expression: "new Intl.DateTimeFormat('en-US', {",
306306
count: 1,
307307
verdict: 'deliberate fallback',

‎packages/plugin-calendar/src/ObjectCalendar.tsx‎

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ import {
7676
applyNonGridRowCeiling,
7777
nonGridRowCeilingQuery,
7878
type NonGridCeilingResult,
79+
isRealCalendarDate,
80+
toDateInputValue,
81+
toDisplayDate,
7982
} from '@object-ui/core';
8083

8184
/**
@@ -316,6 +319,30 @@ function getCalendarConfig(schema: ObjectCalendarSchema): ObjectCalendarConfig |
316319
return null;
317320
}
318321

322+
/**
323+
* The value a moved or quick-created event writes into one of its date fields
324+
* (objectui#10866).
325+
*
326+
* A field declared `date` holds a calendar day, the spec's `YYYY-MM-DD`
327+
* storage form, so it is written as the LOCAL calendar day the user dropped on
328+
* or clicked. ⛔ Never `toISOString()` for it: the event was read at local
329+
* midnight of its day (`toDisplayDate`), and the UTC spelling of a local
330+
* midnight names the PREVIOUS day everywhere east of UTC. Any other declared
331+
* type (`datetime`) keeps its instant, exactly as before.
332+
*
333+
* With no declared type to ask (the adapter exposes no object schema), the
334+
* stored value's own shape answers: the same split `toDisplayDate` made when it
335+
* read the value, so a write never disagrees with the read that placed the
336+
* event. A quick-create has no stored value, so it keeps the instant there.
337+
*/
338+
function toStoredDateValue(date: Date, declaredType: unknown, stored: unknown): string {
339+
const dateOnly =
340+
typeof declaredType === 'string'
341+
? declaredType === 'date'
342+
: typeof stored === 'string' && isRealCalendarDate(stored);
343+
return dateOnly ? toDateInputValue(date) : date.toISOString();
344+
}
345+
319346
/**
320347
* A record the calendar cannot place: the field declared as `startDateField`
321348
* carries no value on it, so there is no date to draw and none is invented
@@ -882,7 +909,11 @@ export const ObjectCalendar: React.FC<ObjectCalendarComponentProps> = ({
882909
return;
883910
}
884911

885-
const start = new Date(startDate);
912+
// A date-only value names a calendar day: `toDisplayDate` reads it at
913+
// LOCAL midnight of that day, where the engine's own parse read UTC
914+
// midnight and put the event in the previous day's cell west of UTC
915+
// (objectui#10866). A value with a time keeps its instant.
916+
const start = toDisplayDate(startDate);
886917
// The guard keeps its ORIGINAL job, on a DIFFERENT fact from the one
887918
// above: a value that is PRESENT but unparseable ('not a date') is
888919
// dropped here, never bucketed as unscheduled. Absent and malformed are
@@ -893,7 +924,7 @@ export const ObjectCalendar: React.FC<ObjectCalendarComponentProps> = ({
893924
id,
894925
title,
895926
start,
896-
end: endDate ? new Date(endDate) : undefined,
927+
end: endDate ? toDisplayDate(endDate) : undefined,
897928
color,
898929
// ⭐ objectui#8026 — the DECLARED key is the answer when there is one.
899930
// `allDayField` was resolved into the config above and named in the
@@ -1028,11 +1059,14 @@ export const ObjectCalendar: React.FC<ObjectCalendarComponentProps> = ({
10281059
const id = record?.id ?? record?._id;
10291060
if (!id || !schema.objectName || !dataSource?.update) return;
10301061

1062+
// A `date` field is written as the calendar day, a `datetime` as the
1063+
// instant (objectui#10866, `toStoredDateValue`).
1064+
const fieldDefs = objectSchema?.fields as Record<string, { type?: unknown } | undefined> | undefined;
10311065
const patch: Record<string, string> = {
1032-
[startDateField]: newStart.toISOString(),
1066+
[startDateField]: toStoredDateValue(newStart, fieldDefs?.[startDateField]?.type, record?.[startDateField]),
10331067
};
10341068
if (endDateField && newEnd) {
1035-
patch[endDateField] = newEnd.toISOString();
1069+
patch[endDateField] = toStoredDateValue(newEnd, fieldDefs?.[endDateField]?.type, record?.[endDateField]);
10361070
}
10371071

10381072
// Optimistic UI update
@@ -1067,7 +1101,7 @@ export const ObjectCalendar: React.FC<ObjectCalendarComponentProps> = ({
10671101
: extractWriteErrorMessage(err) ?? tt('table.saveFailed', 'Save failed')),
10681102
);
10691103
}
1070-
}, [calendarConfig, schema.objectName, dataSource, data, tt]);
1104+
}, [calendarConfig, schema.objectName, dataSource, data, tt, objectSchema]);
10711105

10721106
// Quick-create state: clicking an empty day cell opens a small dialog
10731107
// pre-filled with that date. On submit, dataSource.create() inserts a
@@ -1103,13 +1137,20 @@ export const ObjectCalendar: React.FC<ObjectCalendarComponentProps> = ({
11031137

11041138
setQuickCreate(qc => qc ? { ...qc, submitting: true, error: undefined } : qc);
11051139
const { startDateField, endDateField, titleField } = calendarConfig;
1140+
// A `date` field is written as the calendar day clicked, a `datetime` as
1141+
// the instant (objectui#10866, `toStoredDateValue`).
1142+
const dateFieldDefs = objectSchema?.fields as Record<string, { type?: unknown } | undefined> | undefined;
11061143
const payload: Record<string, any> = {
11071144
[titleField || 'name']: title,
1108-
[startDateField]: quickCreate.start.toISOString(),
1145+
[startDateField]: toStoredDateValue(quickCreate.start, dateFieldDefs?.[startDateField]?.type, undefined),
11091146
};
11101147
// Default end_date to range end (or same as start if not provided).
11111148
if (endDateField) {
1112-
payload[endDateField] = (quickCreate.end ?? quickCreate.start).toISOString();
1149+
payload[endDateField] = toStoredDateValue(
1150+
quickCreate.end ?? quickCreate.start,
1151+
dateFieldDefs?.[endDateField]?.type,
1152+
undefined,
1153+
);
11131154
}
11141155
// Auto-fill required fields the user hasn't provided (e.g. select
11151156
// status, autonumber). Without this the server would 400 on

0 commit comments

Comments
 (0)