Import
import { DatePropertyAccessor } from '@rs-x/core';API Reference
Date accessor implementation used by the index-value-accessor pipeline. It exposes a fixed set of Date parts (local and UTC variants) as named indexes and supports reading and updating those parts.
import { DatePropertyAccessor } from '@rs-x/core';import {
type DateProperty,
InjectionContainer,
RsXCoreInjectionTokens,
RsXCoreModule,
type IDatePropertyAccessor,
} from '@rs-x/core';
await InjectionContainer.load(RsXCoreModule);
const accessor = InjectionContainer.get<IDatePropertyAccessor>(
RsXCoreInjectionTokens.IDatePropertyAccessor,
);
const date = new Date('2024-01-10T00:00:00.000Z');
const property: DateProperty = 'utcYear';
console.log(accessor.getValue(date, property)); // 2024
accessor.setValue(date, property, 2025);
console.log(accessor.getValue(date, property)); // 2025
console.log(accessor.hasValue(date, property)); // trueimport { Inject, RsXCoreInjectionTokens, type IDatePropertyAccessor } from '@rs-x/core';
class MyConsumer {
constructor(
@Inject(RsXCoreInjectionTokens.IDatePropertyAccessor)
private readonly dependency: IDatePropertyAccessor,
) {}
}6 members in this class.
public applies(
context: unknown,
index: DateProperty
): booleanParameters
Returns
boolean
public getIndexes(): IterableIterator<DateProperty>Parameters
No parameters.
Returns
IterableIterator<DateProperty>
public getResolvedValue(
context: Date,
index: DateProperty
): unknownParameters
Returns
unknown
public getValue(
date: Date,
index: DateProperty
): unknownParameters
Returns
unknown
public hasValue(
context: Date,
index: DateProperty
): booleanParameters
Returns
boolean
public setValue(
date: Date,
index: DateProperty,
value: number
): voidParameters
Returns
void