Core Concepts

Dates

Date fields are exposed as expression-friendly properties.

What it means

rs-x maps Date methods to property keys so expressions stay declarative. Use month, year, time, and the UTC variants directly in paths.

This goes through DatePropertyAccessor. The accessor maps each property key to the matching Date getter/setter methods, so you read via keys in expressions and write via Date setter methods.

Example: use invoiceDate.month, not invoiceDate.getMonth inside the expression string.

For mutations, use native setter methods such as setMonth, not direct assignment like invoiceDate.month = ....

Practical value

You get one consistent path style for objects, collections, async values, and dates. Reads and writes on date properties are tracked through the same reactive pipeline.

Key points

Date property reference

dateLocalgetDatesetDateDay of month (1-31) in local time.
hoursLocalgetHourssetHoursHours in local time (0-23).
millisecondsLocalgetMillisecondssetMillisecondsMilliseconds in local time (0-999).
minutesLocalgetMinutessetMinutesMinutes in local time (0-59).
monthLocalgetMonthsetMonthZero-based month (0 = January, 11 = December).
secondsLocalgetSecondssetSecondsSeconds in local time (0-59).
timeEpochgetTimesetTimeUnix epoch milliseconds.
utcDateUTCgetUTCDatesetUTCDateDay of month (1-31) in UTC.
utcHoursUTCgetUTCHourssetUTCHoursHours in UTC (0-23).
utcMillisecondsUTCgetUTCMillisecondssetUTCMillisecondsMilliseconds in UTC (0-999).
utcMinutesUTCgetUTCMinutessetUTCMinutesMinutes in UTC (0-59).
utcMonthUTCgetUTCMonthsetUTCMonthZero-based UTC month.
utcSecondsUTCgetUTCSecondssetUTCSecondsSeconds in UTC (0-59).
utcYearUTCgetUTCFullYearsetUTCFullYearFour-digit UTC year.
yearLocalgetFullYearsetFullYearFour-digit local year.

year example

import { emptyFunction, InjectionContainer, WaitForEvent } from '@rs-x/core';
import { rsx, RsXExpressionParserModule } from '@rs-x/expression-parser';

await InjectionContainer.load(RsXExpressionParserModule);

const model = {
  invoiceDate: new Date('2026-03-13T08:15:20.250Z'),
};

// Read with Date property keys, mutate with Date setter methods.
const expression = rsx<number>('invoiceDate.year')(model);
await new WaitForEvent(expression, 'changed').wait(emptyFunction);
expression.changed.subscribe(() => {
  console.log('year ->', expression.value);
});

const randomInt = (min: number, max: number): number =>
  Math.floor(Math.random() * (max - min + 1)) + min;

setInterval(() => {
  model.invoiceDate.setFullYear(randomInt(2025, 2028));
}, 900);