/** * Luxon DateTime Helpers * * @remarks * This module contains a set of interfaces and utilities for handling Luxon DateTime object operations and conversions. * * @module */ import { DateTime, Zone } from 'luxon'; /** * FHIR Primitive DateType implementation supporting Luxon DateTime object * * @see [Luxon](https://moment.github.io/luxon/#/) * @interface * @category Data Models: PrimitiveType */ export interface DateTypeImpl { /** * Returns a Luxon DateTime object for the PrimitiveType's `getValue()`. * * @remarks * Uses DateTime.fromISO() static method to create a DateTime object. * * @param opts - Optional DateTime options object to affect the creation of the DateTime instance * @returns an instance of a DateTime object * @throws {@link InvalidDateTimeError} if the instantiated DataTime object is invalid * * @see [Luxon DateTime.fromISO()](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso) */ getValueAsDateTime: (opts?: DateTimeUtil.DateTimeOpts) => DateTime | undefined; /** * Returns a Luxon DateTime object having the UTC time zone for the PrimitiveType's `getValue()`. * * @remarks * Uses DateTime.fromISO() static method to create a DateTime object. * * @returns an instance of a DateTime object having the UTC time zone * @throws {@link InvalidDateTimeError} if the instantiated DataTime object is invalid */ getValueAsDateTimeUTC: () => DateTime | undefined; /** * Sets the PrimitiveType's value of the provided dt argument as 'YYYY' * * @param dt - DateTime object from which to obtain a string value * @returns this * @throws {@link InvalidDateTimeError} for an invalid dt argument */ setValueAsYear: (dt: DateTime | undefined) => this; /** * Sets the PrimitiveType's value of the provided dt argument as 'YYYY-MM' * * @param dt - DateTime object from which to obtain a string value * @returns this * @throws {@link InvalidDateTimeError} for an invalid dt argument */ setValueAsYearMonth: (dt: DateTime | undefined) => this; /** * Sets the PrimitiveType's value of the provided dt argument as 'YYYY-MM-DD' * * @param dt - DateTime object from which to obtain a string value * @returns this * @throws {@link InvalidDateTimeError} for an invalid dt argument */ setValueAsDateOnly: (dt: DateTime | undefined) => this; } /** * FHIR Primitive DateTimeType implementation supporting Luxon DateTime object * * @see [Luxon](https://moment.github.io/luxon/#/) * @interface * @category Data Models: PrimitiveType */ export interface DateTimeTypeImpl extends DateTypeImpl { /** * Sets the PrimitiveType's value of the provided dt argument as an ISO datetime string excluding * milliseconds from the format if they are 0 * * @param dt - DateTime object from which to obtain a string value * @returns this * @throws {@link InvalidDateTimeError} for an invalid dt argument */ setValueAsDateTime: (dt: DateTime | undefined) => this; /** * Sets the PrimitiveType's value of the provided dt argument as an ISO datetime string including * milliseconds * * @param dt - DateTime object from which to obtain a string value * @returns this * @throws {@link InvalidDateTimeError} for an invalid dt argument */ setValueAsInstant: (dt: DateTime | undefined) => this; } /** * FHIR Primitive InstantType implementation supporting Luxon DateTime object * * @see [Luxon](https://moment.github.io/luxon/#/) * @interface * @category Data Models: PrimitiveType */ export interface InstantTypeImpl { /** * Returns a Luxon DateTime object for the PrimitiveType's `getValue()`. * * @remarks * Uses DateTime.fromISO() static method to create a DateTime object. * * @param opts - Optional DateTime options object to affect the creation of the DateTime instance * @returns an instance of a DateTime object * @throws {@link InvalidDateTimeError} if the instantiated DataTime object is invalid * * @see [Luxon DateTime.fromISO()](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso) */ getValueAsDateTime: (opts?: DateTimeUtil.DateTimeOpts) => DateTime | undefined; /** * Returns a Luxon DateTime object having the UTC time zone for the PrimitiveType's `getValue()`. * * @remarks * Uses DateTime.fromISO() static method to create a DateTime object. * * @returns an instance of a DateTime object having the UTC time zone * @throws {@link InvalidDateTimeError} if the instantiated DataTime object is invalid */ getValueAsDateTimeUTC: () => DateTime | undefined; /** * Sets the PrimitiveType's value of the provided dt argument as an ISO datetime string including * milliseconds * * @param dt - DateTime object from which to obtain a string value * @returns this * @throws {@link InvalidDateTimeError} for an invalid dt argument */ setValueAsInstant: (dt: DateTime | undefined) => this; } /** * Namespace for handling Luxon DateTime object operations and conversions. * * @remarks * This namespace provides functions to work with Luxon's DateTime instances, providing * helpers to handle FHIR date strings and various formatting needs. * * @privateRemarks * This namespace is used to make it easier to export these items from this FHIR core library * to make them easily available within the generated data models packages. * * @see [Luxon](https://moment.github.io/luxon/#/) */ export declare namespace DateTimeUtil { /** * Luxon DateTime options to affect the creation of the DateTime instance. * * @category Utilities: DateTime * @interface * * @see [opts (Object = {}) options to affect the creation](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso) */ interface DateTimeOpts { /** * Use this zone if no offset is specified in the input string itself. Will also convert the time to this zone. * Defaults to `'local'`. * * @see [Zone](https://moment.github.io/luxon/api-docs/index.html#zone) */ zone?: string | Zone; /** * Override the zone with a fixed-offset zone specified in the string itself, if it specifies one. * Defaults to `false` */ setZone?: boolean; /** * The locale to set on the resulting DateTime instance. * Defaults to the system's locale. */ locale?: string; /** * The output calendar to set on the resulting DateTime instance. */ outputCalendar?: string; /** * The numbering system to set on the resulting DateTime instance. */ numberingSystem?: string; /** * The week settings to set on the resulting DateTime instance. */ weekSettings?: string; } /** * Returns a Luxon DateTime object for the provided ISO 8601 string value. * * @remarks * Uses DateTime.fromISO() static method to create a DateTime object. * * @param value - string that represents an ISO 8601 value used to instantiate a DataTime object * @param opts - Optional DateTime options object to affect the creation of the DateTime instance * @returns an instance of a DateTime object * @throws {@link InvalidDateTimeError} if the instantiated DataTime object is invalid * * @category Utilities: DateTime * @see [Luxon DateTime.fromISO()](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso) */ function getDateTimeObject(value: string | undefined, opts?: DateTimeOpts): DateTime | undefined; /** * Returns a Luxon DateTime object having the UTC time zone for the provided ISO 8601 string value. * * @remarks * Uses DateTime.fromISO() static method to create a DateTime object. * * @param value - string that represents an ISO 8601 value used to instantiate a DataTime object * @returns an instance of a DateTime object having the UTC time zone * @throws {@link InvalidDateTimeError} if the instantiated DataTime object is invalid * * @category Utilities: DateTime * @see [Luxon DateTime.fromISO()](https://moment.github.io/luxon/api-docs/index.html#datetimefromiso) */ function getDateTimeObjectAsUTC(value: string | undefined): DateTime | undefined; /** * Returns the value of the provided dt argument as 'YYYY' * * @param dt - DateTime object from which to obtain a string value * @returns the FHIR primitive date/dateTime value as 'YYYY' * @throws {@link InvalidDateTimeError} for an invalid dt argument * * @category Utilities: DateTime */ function getValueAsYear(dt: unknown): string | undefined; /** * Returns the value of the provided dt argument as 'YYYY-MM' * * @param dt - DateTime object from which to obtain a string value * @returns the FHIR primitive date/dateTime value as 'YYYY-MM' * @throws {@link InvalidDateTimeError} for an invalid dt argument * * @category Utilities: DateTime */ function getValueAsYearMonth(dt: unknown): string | undefined; /** * Returns the value of the provided dt argument as 'YYYY-MM-DD' * * @param dt - DateTime object from which to obtain a string value * @returns the FHIR primitive date/dateTime value as 'YYYY-MM-DD' * @throws {@link InvalidDateTimeError} for an invalid dt argument * * @category Utilities: DateTime */ function getValueAsDateOnly(dt: unknown): string | undefined; /** * Returns the value of the provided dt argument as an ISO datetime string excluding * milliseconds from the format if they are 0 * * @param dt - DateTime object from which to obtain a string value * @returns the FHIR primitive date/dateTime value as an ISO datetime string * @throws {@link InvalidDateTimeError} for an invalid dt argument * * @category Utilities: DateTime */ function getValueAsDateTime(dt: unknown): string | undefined; /** * Returns the value of the provided dt argument as an ISO datetime string including * milliseconds * * @param dt - DateTime object from which to obtain a string value * @returns the FHIR primitive date/dateTime value as an ISO datetime string * @throws {@link InvalidDateTimeError} for an invalid dt argument * * @category Utilities: DateTime */ function getValueAsInstant(dt: unknown): string | undefined; } //# sourceMappingURL=date-time-util.d.ts.map