Skip to content

clock

The grid’s « now », for the few things that depend on the day.

Type() => number
DefaultDate.now
Live update (update())No — read once, when the grid is made
Angularthe [clock] input
<dz-grid>the settings property: el.settings = { clock: … }
Declared inpackages/dom/src/settings.ts

A function giving milliseconds since 1970 UTC, as Date.now does. The grid asks it when it needs today: a date filter’s shortcuts (« today », « the last 7 days », « this month »), the day a date editor and the filters panel open on, and the moment the filters feature counts the next midnight from, when a shortcut in force must move to the new day. The day is the one the clock reads in timeZone.

Give it to fix « now » in tests and screenshots, or to follow a server’s clock rather than the reader’s machine. It is read when the grid is made: update() refuses a new one.

import { createGrid } from '@dzgrid/dom';
import { filters } from '@dzgrid/dom/filters';
import { EN } from '@dzgrid/dom/locales/en';
import { EN_FILTERS } from '@dzgrid/dom/locales/en-filters';
type Visit = { id: string; place: string; on: string };
const serverOffset = 1_250; // ms the server's clock is ahead, measured by the app
createGrid<Visit>(document.getElementById('visits')!, {
rows: [{ id: 'v1', place: 'Herb garden', on: '2026-03-02' }],
columns: [{ id: 'place', header: 'Place' }, { id: 'on', header: 'Visited on', type: 'day' }],
getRowId: (v) => v.id,
messages: { ...EN, text: { ...EN.text, ...EN_FILTERS.text } },
timeZone: 'Europe/London',
clock: () => Date.now() + serverOffset,
features: [filters()],
});