@rschedule/luxon-date-adapter
Version:
An rSchedule DateAdapter for "luxon" DateTime objects.
58 lines (57 loc) • 1.97 kB
TypeScript
import { DateAdapter, DateAdapterBase, DateTime } from '@rschedule/core';
import { DateTime as LuxonDateTime } from 'luxon';
/**
* The `LuxonDateAdapter` is a DateAdapter for `luxon` DateTime
* objects.
*
* It supports timezone handling in so far as luxon supports
* timezone handling. Note: that, if able, luxon always adds
* a timezone to a DateTime (i.e. timezone may never be undefined).
*
* At the moment, that means that serializing to/from iCal will
* always apply a specific timezone (which may or may not be what
* you want). If this is a problem for you, you can try opening
* an issue in the rSchedule monorepo.
*/
export declare class LuxonDateAdapter extends DateAdapterBase {
static readonly date: LuxonDateTime;
static readonly hasTimezoneSupport: true;
/**
* Checks if object is an instance of `LuxonDateTime`
*/
static isDate(object: any): object is LuxonDateTime;
static fromDate(
date: LuxonDateTime,
options?: {
duration?: number;
},
): LuxonDateAdapter;
static fromJSON(json: DateAdapter.JSON): LuxonDateAdapter;
/**
* ### Important!!!
*
* This method expects an *rSchedule* `DateTime` object which bares
* *no relation* to a luxon `DateTime` object. This method is largely
* meant for private, internal rSchedule use.
*
* @param datetime rSchedule DateTime object
*/
static fromDateTime(datetime: DateTime): LuxonDateAdapter;
readonly date: LuxonDateTime;
readonly timezone: string | null;
private _end;
constructor(
date: LuxonDateTime,
options?: {
duration?: number;
generators?: ReadonlyArray<unknown>;
metadata?: DateAdapterBase['metadata'];
},
);
get end(): LuxonDateTime | undefined;
set(prop: 'timezone', value: string | null): this;
set(prop: 'duration', value: number): this;
valueOf(): number;
toJSON(): DateAdapter.JSON;
assertIsValid(): true;
}